コード例 #1
0
ファイル: Temple.php プロジェクト: ZerGabriel/ADR2
 /**
  * @method POST
  * @api resurrect
  */
 public function resurrect()
 {
     $characters = new Character();
     $adr_char = $characters->getCharacterByID($_POST['character_id']);
     $cost = $this->getCosts($_POST['character_id']);
     $cost = $cost['resurrect_price'];
     $user = new User();
     $points = $user->getPoints();
     if ($points['user_points'] < $cost) {
         return $this->response(array('status' => 0, 'message' => ADR::Lang("Adr_lack_points")));
     }
     if ($adr_char['character_hp'] > 0) {
         return $this->response(array('status' => 0, 'message' => ADR::Lang("Adr_temple_heal_instead")));
     }
     $user->subtractPoints($cost);
     $this->replenish($adr_char);
     return $this->response(array('status' => 1, 'current_points' => $points['user_points'] - $cost, 'message' => ADR::Lang("Adr_temple_resurrected")));
 }
コード例 #2
0
ファイル: Character.php プロジェクト: ZerGabriel/ADR2
 /**
  * @method POST
  * @api create
  *
  * ints - race_id, element_id, alignment_id, class_id
  *        element_id, alignment_id, character_might, character_dexterity, character_constitution, character_intelligence, character_wisdom, character_charisma, magic_attack, magic_resistance
  * string - character_name, character_desc
  */
 public function create()
 {
     $userID = User::getID();
     $db = DB::instance();
     $races = new Races();
     $race = $races->getRaceByID($_POST['race_id']);
     $elements = new Elements();
     $element = $elements->getElementByID($_POST['element_id']);
     $alignments = new Alignments();
     $alignment = $alignments->getAlignmentByID($_POST['alignment_id']);
     $classes = new Classes();
     $class = $classes->getClassByID($_POST['class_id']);
     $config = ADR::getGeneralConfig();
     if (!$this->verify_roll($_POST)) {
         return $this->response(array('status' => 0, 'message' => 'Invalid roll'));
     }
     $character_name = $_POST['character_name'];
     $character_desc = $_POST['character_desc'];
     $character_race = $_POST['race_id'];
     $character_class = $_POST['class_id'];
     $character_hp = $class['class_base_hp'];
     $character_hp_max = $class['class_base_hp'];
     $character_mp = $class['class_base_mp'];
     $character_mp_max = $class['class_base_mp'];
     $character_ac = $class['class_base_ac'];
     $character_element = $_POST['element_id'];
     $character_alignment = $_POST['alignment_id'];
     $character_might = $_POST['character_might'] + ($race['race_might_bonus'] - $race['race_might_penalty']);
     $character_dexterity = $_POST['character_dexterity'] + ($race['race_dexterity_bonus'] - $race['race_dexterity_penalty']);
     $character_constitution = $_POST['character_constitution'] + ($race['race_constitution_bonus'] - $race['race_constitution_penalty']);
     $character_intelligence = $_POST['character_intelligence'] + ($race['race_intelligence_bonus'] - $race['race_intelligence_penalty']);
     $character_wisdom = $_POST['character_wisdom'] + ($race['race_wisdom_bonus'] - $race['race_wisdom_penalty']);
     $character_charisma = $_POST['character_charisma'] + ($race['race_charisma_bonus'] - $race['race_charisma_penalty']);
     $character_magic_attack = $_POST['magic_attack'] + ($race['race_magic_attack_bonus'] - $race['race_magic_attack_penalty']);
     $character_magic_resistance = $_POST['magic_resistance'] + ($race['race_magic_resistance_bonus'] - $race['race_magic_resistance_penalty']);
     $character_skill_mining = 1 + ($race['race_skill_mining_bonus'] + $element['element_skill_mining_bonus']);
     $character_skill_stone = 1 + ($race['race_skill_stone_bonus'] + $element['element_skill_stone_bonus']);
     $character_skill_forge = 1 + ($race['race_skill_forge_bonus'] + $element['element_skill_forge_bonus']);
     $character_skill_enchantment = 1 + ($race['race_skill_enchantment_bonus'] + $element['element_skill_enchantment_bonus']);
     $character_skill_trading = 1 + ($race['race_skill_trading_bonus'] + $element['element_skill_trading_bonus']);
     $character_skill_thief = 1 + ($race['race_skill_thief_bonus'] + $element['element_skill_thief_bonus']);
     $character_birth = time();
     $character_battle_limit = $config['character_battle_limit'];
     $character_skill_limit = $config['character_skill_limit'];
     $character_trading_limit = $config['character_trading_limit'];
     $character_thief_limit = $config['character_thief_limit'];
     $character_id = $db->insert('adr_characters', array('userID' => $userID, 'character_name' => $character_name, 'character_desc' => $character_desc, 'character_race' => $character_race, 'character_class' => $character_class, 'character_hp' => $character_hp, 'character_hp_max' => $character_hp_max, 'character_mp' => $character_mp, 'character_mp_max' => $character_mp_max, 'character_ac' => $character_ac, 'character_element' => $character_element, 'character_alignment' => $character_alignment, 'character_might' => $character_might, 'character_dexterity' => $character_dexterity, 'character_constitution' => $character_constitution, 'character_intelligence' => $character_intelligence, 'character_wisdom' => $character_wisdom, 'character_charisma' => $character_charisma, 'character_magic_attack' => $character_magic_attack, 'character_magic_resistance' => $character_magic_resistance, 'character_skill_mining' => $character_skill_mining, 'character_skill_stone' => $character_skill_stone, 'character_skill_forge' => $character_skill_forge, 'character_skill_enchantment' => $character_skill_enchantment, 'character_skill_trading' => $character_skill_trading, 'character_skill_thief' => $character_skill_thief, 'character_birth' => $character_birth, 'character_battle_limit' => $character_battle_limit, 'character_skill_limit' => $character_skill_limit, 'character_trading_limit' => $character_trading_limit, 'character_thief_limit' => $character_thief_limit));
     if ($character_id == false) {
         throw new Exception($db->getErrorMessage());
     }
     return $this->response(array('status' => 1, 'character_id' => $character_id));
 }
コード例 #3
0
ファイル: Battle.php プロジェクト: ZerGabriel/ADR2
 private function win($bat, $monster, $challenger)
 {
     // The monster is dead , give money and xp to the users , then update the database
     $adr_general = ADR::getGeneralConfig();
     // Get the experience earned
     $exp = rand($adr_general['battle_base_exp_min'], $adr_general['battle_base_exp_max']);
     if ($monster['monster_level'] - $challenger['character_level'] > 1) {
         $exp = floor(($monster['monster_level'] - $challenger['character_level']) * $adr_general['battle_base_exp_modifier'] / 100);
     }
     // Get the money earned
     $reward = rand($adr_general['battle_base_reward_min'], $adr_general['battle_base_reward_max']);
     if ($monster['monster_level'] - $challenger['character_level'] > 1) {
         $reward = floor(($monster['monster_level'] - $challenger['character_level']) * $adr_general['battle_base_reward_modifier'] / 100);
     }
     $this->updateBattleList(array('battle_result' => 1, 'battle_opponent_hp' => 0, 'battle_finish' => time(), 'battle_text' => ''));
     $user = new User();
     $points = $user->getPoints();
     $user->addPoints($reward);
     /*$sql = " UPDATE  " . ADR_CHARACTERS_TABLE . " 
       SET character_xp = character_xp + $exp ,
           character_victories = character_victories + 1 ,
           character_sp = character_sp + '" . $bat['battle_opponent_sp'] . "'
       WHERE character_id = $user_id ";*/
     $db = DB::instance();
     $db->execute("UPDATE adr_characters SET\n                    character_xp = character_xp + {$exp},\n                    character_victories = character_victories + 1,\n                    character_sp = character_sp + {$bat['battle_opponent_sp']}\n                WHERE character_id = {$bat['battle_challenger_id']}");
     /*
             // Remove item stolen status
             $sql = "UPDATE " . ADR_SHOPS_ITEMS_TABLE . "
                 SET item_monster_thief = 0 
                 WHERE item_owner_id = $user_id ";
             if( !($result = $db->sql_query($sql)) )
             {
                 message_die(GENERAL_ERROR, 'Could not update stolen item status', '', __LINE__, __FILE__, $sql);
             }
     
             // Delete broken items from users inventory
             $sql = " DELETE FROM " . ADR_SHOPS_ITEMS_TABLE . "
                 WHERE item_duration < 1 
                 AND item_owner_id = $user_id ";
             if( !($result = $db->sql_query($sql)) )
             {
                 message_die(GENERAL_ERROR, 'Could not delete broken items', '', __LINE__, __FILE__, $sql);
             }*/
     $user_points = $points['user_points'] + $reward;
     $message = array(sprintf(ADR::Lang('Adr_battle_won'), $bat['battle_challenger_dmg'], $exp, $bat['battle_opponent_sp'], $reward, $adr_general['points_name']));
     $stolen = false;
     if ($stolen && $stolen['item_name'] != '') {
         array_push($message, sprintf(ADR::Lang('Adr_battle_stolen_items'), $monster['monster_name']));
     }
     return array('message' => $message, 'exp' => $exp, 'sp' => $bat['battle_opponent_sp'], 'reward' => $reward, 'user_points' => $user_points);
 }
コード例 #4
0
ファイル: Stores.php プロジェクト: ZerGabriel/ADR2
 /**
  * @method POST
  * @api name
  */
 public function name()
 {
     // if not logged in, getID is 0 (anonymous)
     Analytics::track('saidhello', 'HelloWorld', User::getID());
     return $this->response(array('status' => 1, 'message' => "Hello " . $_POST['myName'] . "!"));
 }