示例#1
0
文件: Code.php 项目: synthx/infuse
 /**
  * Title of code page
  *
  * @param int $action
  * @param int $param
  */
 public function type($action, $param)
 {
     switch ($action) {
         case 1:
             return 'Don de ' . $param . ' points';
             break;
         case 2:
             return 'Don du ' . \App\Model\Tokens::find($param)->name;
             break;
         case 3:
             return 'Don de l\'objet ' . \App\Model\ItemTemplate::find($param)->name;
             break;
         case 4:
             return 'Don de la ' . \App\Model\Itemset::find($param)->name;
             break;
     }
 }
示例#2
0
 /**
  * Use token
  * POST
  *
  * @param Request $request
  * @param int $id
  * @param string $name
  * @return Response
  */
 public function useToken(Request $request, $id, $name)
 {
     $token = TokensManager::find($id);
     $this->validate($request, ['player' => 'required|numeric|exists:personnages,guid']);
     $tokensAccount = TokensAccountManager::where('guid', Auth::user()->guid)->where('token', $id)->first();
     $tokensAccount->quantity -= 1;
     $tokensAccount->save();
     $this->_giveObject($request->player, $this->_generateRandomObject($token->items));
     if ($tokensAccount->quantity == 0) {
         $tokensAccount->delete();
     }
     return redirect()->route('gift.tokens');
 }