示例#1
0
 private function buildPlayerGroup($tech, $fleets)
 {
     $playerObj = new Player(1);
     $playerObj->setName('bot');
     $playerObj->setTech($tech['weapons'], $tech['shields'], $tech['armour']);
     foreach ($fleets as $idFleet => $fleet) {
         $fleetObj = new Fleet($idFleet);
         foreach ($fleet as $id => $count) {
             $count = floor($count);
             $id = floor($id);
             if ($count > 0 && $id > 0) {
                 $fleetObj->addShipType($this->getShipType($id, $count));
             }
         }
         if (!$fleetObj->isEmpty()) {
             $playerObj->addFleet($fleetObj);
         }
     }
     if ($playerObj->isEmpty()) {
         die("<meta http-equiv=\"refresh\" content=2;\"WebTest.php\">There should be at least an attacker and defender");
     }
     $playerGroupObj = new PlayerGroup();
     $playerGroupObj->addPlayer($playerObj);
     return $playerGroupObj;
 }
示例#2
0
 protected function getAsObject($row)
 {
     $result = new Player();
     $result->setNew(false);
     $result->setPlayerId(Singleton::create("NullConverter")->fromDBtoDOM($row["playerId"]));
     $result->setName(Singleton::create("NullConverter")->fromDBtoDOM($row["name"]));
     $result->setTeamId(Singleton::create("NullConverter")->fromDBtoDOM($row["teamId"]));
     return $result;
 }
示例#3
0
            $check_name_in_database->find($newchar_name);
            if ($check_name_in_database->isLoaded()) {
                $newchar_errors[] = 'This name is already used. Please choose another name!';
            }
            $charToEdit = new Player($_REQUEST['player_id']);
            if (!$charToEdit->isLoaded()) {
                $newchar_errors[] = 'This player does not exist.';
            }
            if ($charToEdit->isOnline()) {
                $newchar_errors[] = 'This player is ONLINE. Logout first.';
            } elseif ($account_logged->getID() != $charToEdit->getAccountID()) {
                $newchar_errors[] = 'This player is not on your account.';
            }
            if (empty($newchar_errors)) {
                echo 'Name of character <b>' . htmlspecialchars($charToEdit->getName()) . '</b> changed to <b>' . htmlspecialchars($newchar_name) . '</b>';
                $charToEdit->setName($newchar_name);
                $charToEdit->save();
                $account_logged->setCustomField('premium_points', $account_logged->getCustomField('premium_points') - $changeNameCost);
            } else {
                echo 'Some errors occured:<br />';
                foreach ($newchar_errors as $e) {
                    echo '<li>' . $e . '</li>';
                }
                echo '<br /><a href="?subtopic=changename"><b>BACK</b></a>';
            }
        }
    } else {
        echo 'You don\'t have premium points. You need ' . $changeNameCost . '.';
    }
} else {
    echo 'You must login first.';
         $newchar_errors[] .= 'Wrong characters configuration. Try again or contact with admin. ADMIN: Edit file config/config.php and set valid characters to copy names. Character to copy <b>' . htmlspecialchars($char_to_copy_name) . '</b> doesn\'t exist.';
     }
 }
 if (empty($newchar_errors)) {
     // load items and skills of player before we change ID
     $char_to_copy->getItems()->load();
     $char_to_copy->loadSkills();
     if ($newchar_sex == "0") {
         $char_to_copy->setLookType(136);
     }
     $char_to_copy->setID(null);
     // save as new character
     $char_to_copy->setLastIP(0);
     $char_to_copy->setLastLogin(0);
     $char_to_copy->setLastLogout(0);
     $char_to_copy->setName($newchar_name);
     $char_to_copy->setAccount($account_logged);
     $char_to_copy->setSex($newchar_sex);
     $char_to_copy->setTown($newchar_town);
     $char_to_copy->setPosX(0);
     $char_to_copy->setPosY(0);
     $char_to_copy->setPosZ(0);
     $char_to_copy->setWorldID((int) $world_id);
     $char_to_copy->setCreateIP(Visitor::getIP());
     $char_to_copy->setCreateDate(time());
     $char_to_copy->setSave();
     // make character saveable
     $char_to_copy->save();
     // now it will load 'id' of new player
     if ($char_to_copy->isLoaded()) {
         $char_to_copy->saveItems();
示例#5
0
         $newPlayer->setSkillCount(1, 0);
         $newPlayer->setSkillCount(2, 0);
         $newPlayer->setSkillCount(3, 0);
         $newPlayer->setSkillCount(4, 0);
         $newPlayer->setSkillCount(5, 0);
         $newPlayer->setSkillCount(6, 0);
         $newPlayer->save();
     }
     if ($newPlayer->isLoaded()) {
         foreach ($samplePlayers as $vocationID => $name) {
             $samplePlayer = new Player($name, Player::LOADTYPE_NAME);
             if (!$samplePlayer->isLoaded()) {
                 $samplePlayer = new Player('Account Manager', Player::LOADTYPE_NAME);
                 $samplePlayer->setID(null);
                 // save as new player, not edited
                 $samplePlayer->setName($name);
                 $samplePlayer->setVocation($vocationID);
                 $samplePlayer->setGroupID(1);
                 $samplePlayer->setLookType(128);
                 $samplePlayer->save();
                 echo '<span style="color:green">Added sample character: </span><span style="color:green;font-weight:bold">' . $name . '</span><br/>';
             } else {
                 echo 'Sample character: <span style="font-weight:bold">' . $name . '</span> already exist in database<br/>';
             }
         }
     } else {
         new Error_Critic('', 'Character <i>Account Manager</i> does not exist. Cannot install sample characters!');
     }
 } elseif ($step == 5) {
     echo '<h1>STEP ' . $step . '</h1>Set Admin Account<br>';
     if (empty($_REQUEST['saveaccpassword'])) {
示例#6
0
function getPlayerGroupFromQuery($result, $targetUser = false)
{
    $playerGroup = new PlayerGroup();
    while ($fleetRow = mysql_fetch_assoc($result)) {
        //making the current fleet object
        $serializedTypes = explode(';', $fleetRow['fleet_array']);
        $idPlayer = $fleetRow['fleet_owner'];
        $fleet = new Fleet($fleetRow['fleet_id']);
        foreach ($serializedTypes as $serializedType) {
            list($id, $count) = explode(',', $serializedType);
            if ($id != 0 && $count != 0) {
                $fleet->addShipType(getShipType($id, $count));
            }
        }
        //making the player object and add it to playerGroup object
        if (!$playerGroup->existPlayer($idPlayer)) {
            $player_info = $targetUser !== false && $targetUser['id'] == $idPlayer ? $targetUser : doquery("SELECT * FROM {{table}} WHERE id ={$idPlayer}", 'users', true);
            $player = new Player($idPlayer, array($fleet));
            $player->setTech($player_info['military_tech'], $player_info['shield_tech'], $player_info['defence_tech']);
            $player->setName($player_info['name']);
            $playerGroup->addPlayer($player);
        } else {
            $playerGroup->getPlayer($idPlayer)->addFleet($fleet);
        }
    }
    return $playerGroup;
}
示例#7
0
 /**
  * getPlayerGroupFromQuery
  *
  * @param array   $result      Result
  * @param boolean $target_user Target User
  *
  * @return \PlayerGroup
  */
 private function getPlayerGroupFromQuery($result, $target_user = false)
 {
     $playerGroup = new PlayerGroup();
     while ($fleet_row = parent::$db->fetch_assoc($result)) {
         //making the current fleet object
         $serializedTypes = explode(';', $fleet_row['fleet_array']);
         $idPlayer = $fleet_row['fleet_owner'];
         $fleet = new Fleet($fleet_row['fleet_id']);
         foreach ($serializedTypes as $serializedType) {
             if (!empty($serializedType)) {
                 list($id, $count) = explode(',', $serializedType);
                 if ($id != 0 && $count != 0) {
                     $fleet->addShipType($this->getShipType($id, $count));
                 }
             }
         }
         //making the player object and add it to playerGroup object
         if (!$playerGroup->existPlayer($idPlayer)) {
             if ($target_user !== false && $target_user['user_id'] == $idPlayer) {
                 $player_info = $target_user;
             } else {
                 $player_info = parent::$db->query_fetch("SELECT u.user_name,\n                            r.research_weapons_technology,\n                            r.research_shielding_technology,\n                            r.research_armour_technology\n                        FROM " . USERS . " AS u\n                            INNER JOIN " . RESEARCH . " AS r ON r.research_user_id = u.user_id\n                        WHERE u.user_id = '" . $idPlayer . "';");
             }
             $player = new Player($idPlayer, array($fleet));
             $player->setTech($player_info['research_weapons_technology'], $player_info['research_shielding_technology'], $player_info['research_armour_technology']);
             $player->setName($player_info['user_name']);
             $playerGroup->addPlayer($player);
         } else {
             $playerGroup->getPlayer($idPlayer)->addFleet($fleet);
         }
     }
     return $playerGroup;
 }