Skip to content

Commit

Permalink
Displaying map
Browse files Browse the repository at this point in the history
- navigation
  • Loading branch information
Spamercz committed Feb 8, 2016
1 parent d70fcd5 commit cc577b9
Show file tree
Hide file tree
Showing 13 changed files with 450 additions and 432 deletions.
1 change: 1 addition & 0 deletions App/Config/config.neon
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ services:
- App\GameModule\Model\Event\ProcessEvents
- App\GameModule\Model\Building\BuildingAvailabilityService
- App\GameModule\Model\Event\ProcessCulturePoints
- App\GameModule\Model\Diplomacy\DiplomacyModel

# commands
-
Expand Down
65 changes: 33 additions & 32 deletions App/FrontModule/Model/VData/VillageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,38 +81,39 @@ public function getVillage($id)
/** @var \stdClass $VData */
$VData = $this->VDataModel->getByWId($id);
$village = new App\GameModule\DTO\Village();

/** @var \stdClass $owner */
$owner = $this->userModel->get($VData->owner);
$village->setOwner($owner);

$village->setId($VData->wref);

$village->setActualWood($VData->wood);
$village->setActualClay($VData->clay);
$village->setActualIron($VData->iron);
$village->setActualCrop($VData->crop);
$village->setStorage($VData->maxstore);
$village->setGranary($VData->maxcrop);

$village->setUpkeep($VData->pop);

$village->setName($VData->name);
$village->setLoyalty($VData->loyalty);
$village->setCapital($VData->capital);

$village->setType($VData->type);
$village->setNatar($VData->natar);
$village->setCulturePoints($VData->cp);

$FData = $this->FDataModel->getByVref($village->getId())->toArray();
$village->setFData($FData);

$village->setProductionWood($this->productionService->getProductionWood($village));
$village->setProductionClay($this->productionService->getProductionClay($village));
$village->setProductionIron($this->productionService->getProductionIron($village));
$village->setProductionCrop($this->productionService->getProductionCrop($village));
$village->setMaxUpkeep($this->productionService->getProductionCrop($village));
$village->setId($id);
if ($VData) {
/** @var \stdClass $owner */
$owner = $this->userModel->get($VData->owner);
$village->setOwner($owner);

$village->setActualWood($VData->wood);
$village->setActualClay($VData->clay);
$village->setActualIron($VData->iron);
$village->setActualCrop($VData->crop);
$village->setStorage($VData->maxstore);
$village->setGranary($VData->maxcrop);

$village->setUpkeep($VData->pop);

$village->setName($VData->name);
$village->setLoyalty($VData->loyalty);
$village->setCapital($VData->capital);

$village->setType($VData->type);
$village->setNatar($VData->natar);
$village->setCulturePoints($VData->cp);
$village->setPopulation($VData->pop);

$FData = $this->FDataModel->getByVref($village->getId())->toArray();
$village->setFData($FData);

$village->setProductionWood($this->productionService->getProductionWood($village));
$village->setProductionClay($this->productionService->getProductionClay($village));
$village->setProductionIron($this->productionService->getProductionIron($village));
$village->setProductionCrop($this->productionService->getProductionCrop($village));
$village->setMaxUpkeep($this->productionService->getProductionCrop($village));
}

return $village;
}
Expand Down
52 changes: 52 additions & 0 deletions App/FrontModule/Model/WData/WDataModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,58 @@ class WDataModel extends App\Model\BaseModel
/** @var int */
private $worldSize;

public static $mapCoordinates = [
"53, 137, 90, 157, 53, 177, 16, 157",
"89, 117, 126, 137, 89, 157, 52, 137",
"125, 97, 162, 117, 125, 137, 88, 117",
"161, 77, 198, 97, 161, 117, 124, 97",
"197, 57, 234, 77, 197, 97, 160, 77",
"233, 37, 270, 57, 233, 77, 196, 57",
"269, 17, 306, 37, 269, 57, 232, 37",
"90, 157, 127, 177, 90, 197, 53, 177",
"126, 137, 163, 157, 126, 177, 89, 157",
"162, 117, 199, 137, 162, 157, 125, 137",
"198, 97, 235, 117, 198, 137, 161, 117",
"234, 77, 271, 97, 234, 117, 197, 97",
"270, 57, 307, 77, 270, 97, 233, 77",
"306, 37, 343, 57, 306, 77, 269, 57",
"127, 177, 164, 197, 127, 217, 90, 197",
"163, 157, 200, 177, 163, 197, 126, 177",
"199, 137, 236, 157, 199, 177, 162, 157",
"235, 117, 272, 137, 235, 157, 198, 137",
"271, 97, 308, 117, 271, 137, 234, 117",
"307, 77, 344, 97, 307, 117, 270, 97",
"343, 57, 380, 77, 343, 97, 306, 77",
"164, 197, 201, 217, 164, 237, 127, 217",
"200, 177, 237, 197, 200, 217, 163, 197",
"236, 157, 273, 177, 236, 197, 199, 177",
"272, 137, 309, 157, 272, 177, 235, 157",
"308, 117, 345, 137, 308, 157, 271, 137",
"344, 97, 381, 117, 344, 137, 307, 117",
"380, 77, 417, 97, 380, 117, 343, 97",
"201, 217, 238, 237, 201, 257, 164, 237",
"237, 197, 274, 217, 237, 237, 200, 217",
"273, 177, 310, 197, 273, 217, 236, 197",
"309, 157, 346, 177, 309, 197, 272, 177",
"345, 137, 382, 157, 345, 177, 308, 157",
"381, 117, 418, 137, 381, 157, 344, 137",
"417, 97, 454, 117, 417, 137, 380, 117",
"238, 237, 275, 257, 238, 277, 201, 257",
"274, 217, 311, 237, 274, 257, 237, 237",
"310, 197, 347, 217, 310, 237, 273, 217",
"346, 177, 383, 197, 346, 217, 309, 197",
"382, 157, 419, 177, 382, 197, 345, 177",
"418, 137, 455, 157, 418, 177, 381, 157",
"454, 117, 491, 137, 454, 157, 417, 137",
"275, 257, 312, 277, 275, 297, 238, 277",
"311, 237, 348, 257, 311, 277, 274, 257",
"347, 217, 384, 237, 347, 257, 310, 237",
"383, 197, 420, 217, 383, 237, 346, 217",
"419, 177, 456, 197, 419, 217, 382, 197",
"455, 157, 492, 177, 455, 197, 418, 177",
"491, 137, 528, 157, 491, 177, 454, 157",
];


public function __construct(
$worldSize,
Expand Down
2 changes: 1 addition & 1 deletion App/GameModule/Controls/Header/HeaderControl.latte
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<div id="mtop">
<a href="{plink ':Game:OuterVillage:default', $villageId}" id="n1" accesskey="1"><img src="{$baseUrl}/img/x.gif" title="Village overview" alt="Village overview" /></a>
<a href="{plink ':Game:InnerVillage:default', $villageId}" id="n2" accesskey="2"><img src="{$baseUrl}/img/x.gif" title="Village centre" alt="Village centre" /></a>
<a href="{plink ':Game:Map:default'}" id="n3" accesskey="3"><img src="{$baseUrl}/img/x.gif" title="Map" alt="Map" /></a>
<a href="{plink ':Game:Map:default', $villageId, $villageId}" id="n3" accesskey="3"><img src="{$baseUrl}/img/x.gif" title="Map" alt="Map" /></a>
<a href="{plink ':Game:Statistics:default'}" id="n4" accesskey="4"><img src="{$baseUrl}/img/x.gif" title="Statistics" alt="Statistics" /></a>
<div id="n5" n:class="
$unread && ! $report ? i2,
Expand Down
5 changes: 5 additions & 0 deletions App/GameModule/Controls/Header/HeaderControl.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,12 @@ public function render()
$field = $this->VDataModel->getByUser($this->presenter->user->getId());
$id = $field->wref;
}
$wref = $this->presenter->getParameter('wref');
if ( ! $wref) {
$wref = $id;
}
$this->template->villageId = $id;
$this->template->wref = $wref;
$this->template->unread = $this->MDataModel->countUnread($this->presenter->getUser()->getId()) ? TRUE : FALSE;
$this->template->report = $this->NDataModel->countUnread($this->presenter->getUser()->getId()) ? TRUE : FALSE;
$this->template->plusActive = $this->userService->hasPlus($this->presenter->getUser()->getId());
Expand Down
19 changes: 19 additions & 0 deletions App/GameModule/DTO/Village.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ class Village
/** @var int */
private $culturePoints;

/** @var int */
private $population;

/**
* @return int
Expand Down Expand Up @@ -401,4 +403,21 @@ public function setCulturePoints($culturePoints)
$this->culturePoints = $culturePoints;
}


/**
* @return int
*/
public function getPopulation()
{
return $this->population;
}


/**
* @param int $population
*/
public function setPopulation($population)
{
$this->population = $population;
}
}
74 changes: 74 additions & 0 deletions App/GameModule/Model/Diplomacy/DiplomacyModel.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?php
namespace App\GameModule\Model\Diplomacy;

use App;

class DiplomacyModel extends App\Model\BaseModel
{
protected $table = 'diplomacy';

const ALLIED = 1;
const NEUTRAL = 2;
const WAR = 3;


public function getAliData($alliance1, $alliance2)
{
return $this->database->select('*')->from($this->table)
->where('alli1 = %i', $alliance1)
->where('alli2 = %i', $alliance2)
->fetchAll();
}


/**
* @param int $alliance1
* @param int $alliance2
* @return \Dibi\Row|FALSE
*/
public function atAlliance($alliance1, $alliance2)
{
$found = $this->database->select('*')->from($this->table)
->where('alli1 = %i', $alliance1)
->where('alli2 = %i', $alliance2)
->where('type = %i', self::ALLIED)
->where('accepted = 1')
->fetch();
if ( ! $found) {
$found = $this->database->select('*')->from($this->table)
->where('alli2 = %i', $alliance1)
->where('alli1 = %i', $alliance2)
->where('type = %i', self::ALLIED)
->where('accepted = 1')
->fetch();
}

return $found;
}


/**
* @param int $alliance1
* @param int $alliance2
* @return \Dibi\Row|FALSE
*/
public function atWar($alliance1, $alliance2)
{
$found = $this->database->select('*')->from($this->table)
->where('alli1 = %i', $alliance1)
->where('alli2 = %i', $alliance2)
->where('type = %i', self::WAR)
->where('accepted = 1')
->fetch();
if ( ! $found) {
$found = $this->database->select('*')->from($this->table)
->where('alli2 = %i', $alliance1)
->where('alli1 = %i', $alliance2)
->where('type = %i', self::WAR)
->where('accepted = 1')
->fetch();
}

return $found;
}
}
Loading

0 comments on commit cc577b9

Please sign in to comment.