mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-08-12 22:31:02 +00:00
Additions
+Added the beerfest (in the brewery) +Added a better catapult targets checking system +Updated the sql struct with the new one
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
-- 21.09.2018 changed a column type and added a column, changed 23 attributes and 12 columns default value
|
||||||
|
ALTER TABLE `s1_a2b` CHANGE `ckey` `ckey` CHAR(10) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0';
|
||||||
|
ALTER TABLE `s1_vdata` CHANGE `owner` `owner` INT(11) NOT NULL DEFAULT '5', CHANGE `name` `name` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_general_ci NULL, CHANGE `capital` `capital` TINYINT(1) NOT NULL DEFAULT '0', CHANGE `pop` `pop` INT(11) NOT NULL DEFAULT '2', CHANGE `cp` `cp` INT(11) NOT NULL DEFAULT '0', CHANGE `celebration` `celebration` INT(11) NOT NULL DEFAULT '0', CHANGE `type` `type` INT(11) NOT NULL DEFAULT '3', CHANGE `wood` `wood` FLOAT(12,2) NOT NULL DEFAULT '0', CHANGE `clay` `clay` FLOAT(12,2) NOT NULL DEFAULT '0', CHANGE `iron` `iron` FLOAT(12,2) NOT NULL DEFAULT '0', CHANGE `maxstore` `maxstore` INT(11) NOT NULL DEFAULT '0', CHANGE `crop` `crop` FLOAT(12,2) NOT NULL DEFAULT '0', CHANGE `maxcrop` `maxcrop` INT(11) NOT NULL DEFAULT '0', CHANGE `lastupdate` `lastupdate` INT(11) NOT NULL DEFAULT '0', CHANGE `lastupdate2` `lastupdate2` INT(11) NOT NULL DEFAULT '0', CHANGE `loyalty` `loyalty` FLOAT(9,6) NOT NULL DEFAULT '100.000000', CHANGE `exp1` `exp1` INT(11) NOT NULL DEFAULT '0', CHANGE `exp2` `exp2` INT(11) NOT NULL DEFAULT '0', CHANGE `exp3` `exp3` INT(11) NOT NULL DEFAULT '0', CHANGE `created` `created` INT(11) NOT NULL DEFAULT '0', CHANGE `natar` `natar` TINYINT(1) NOT NULL DEFAULT '0', CHANGE `starv` `starv` INT(11) NOT NULL DEFAULT '0', CHANGE `starvupdate` `starvupdate` INT(11) NOT NULL DEFAULT '0', CHANGE `evasion` `evasion` TINYINT(1) NOT NULL DEFAULT '0';
|
||||||
|
ALTER TABLE `s1_users` ADD `beerfest` INT(11) NOT NULL DEFAULT '0' AFTER `timestamp`;
|
||||||
|
|
||||||
-- 19.09.2018 added a column, an index, changed 15 columns default value and 14 columns attribute
|
-- 19.09.2018 added a column, an index, changed 15 columns default value and 14 columns attribute
|
||||||
ALTER TABLE `s1_a2b` ADD `from` INT(11) NOT NULL AFTER `ckey`;
|
ALTER TABLE `s1_a2b` ADD `from` INT(11) NOT NULL AFTER `ckey`;
|
||||||
ALTER TABLE `s1_a2b` CHANGE `id` `id` INT(11) NOT NULL AUTO_INCREMENT, CHANGE `ckey` `ckey` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0', CHANGE `from` `from` INT(11) NOT NULL DEFAULT '0', CHANGE `to` `to` INT(11) NOT NULL DEFAULT '0', CHANGE `u1` `u1` INT(11) NOT NULL DEFAULT '0', CHANGE `u2` `u2` INT(11) NOT NULL DEFAULT '0', CHANGE `u3` `u3` INT(11) NOT NULL DEFAULT '0', CHANGE `u4` `u4` INT(11) NOT NULL DEFAULT '0', CHANGE `u5` `u5` INT(11) NOT NULL DEFAULT '0', CHANGE `u6` `u6` INT(11) NOT NULL DEFAULT '0', CHANGE `u7` `u7` INT(11) NOT NULL DEFAULT '0', CHANGE `u8` `u8` INT(11) NOT NULL DEFAULT '0', CHANGE `u9` `u9` INT(11) NOT NULL DEFAULT '0', CHANGE `u10` `u10` INT(11) NOT NULL DEFAULT '0', CHANGE `u11` `u11` INT(11) NOT NULL DEFAULT '0', CHANGE `type` `type` SMALLINT(1) NOT NULL DEFAULT '0';
|
ALTER TABLE `s1_a2b` CHANGE `id` `id` INT(11) NOT NULL AUTO_INCREMENT, CHANGE `ckey` `ckey` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0', CHANGE `from` `from` INT(11) NOT NULL DEFAULT '0', CHANGE `to` `to` INT(11) NOT NULL DEFAULT '0', CHANGE `u1` `u1` INT(11) NOT NULL DEFAULT '0', CHANGE `u2` `u2` INT(11) NOT NULL DEFAULT '0', CHANGE `u3` `u3` INT(11) NOT NULL DEFAULT '0', CHANGE `u4` `u4` INT(11) NOT NULL DEFAULT '0', CHANGE `u5` `u5` INT(11) NOT NULL DEFAULT '0', CHANGE `u6` `u6` INT(11) NOT NULL DEFAULT '0', CHANGE `u7` `u7` INT(11) NOT NULL DEFAULT '0', CHANGE `u8` `u8` INT(11) NOT NULL DEFAULT '0', CHANGE `u9` `u9` INT(11) NOT NULL DEFAULT '0', CHANGE `u10` `u10` INT(11) NOT NULL DEFAULT '0', CHANGE `u11` `u11` INT(11) NOT NULL DEFAULT '0', CHANGE `type` `type` SMALLINT(1) NOT NULL DEFAULT '0';
|
||||||
|
|||||||
@@ -3,6 +3,8 @@
|
|||||||
namespace TravianZ\Data\Buildings;
|
namespace TravianZ\Data\Buildings;
|
||||||
|
|
||||||
use TravianZ\Entity\Building;
|
use TravianZ\Entity\Building;
|
||||||
|
use TravianZ\Entity\Village;
|
||||||
|
use TravianZ\Entity\BeerFest;
|
||||||
|
|
||||||
final class Brewery extends Building
|
final class Brewery extends Building
|
||||||
{
|
{
|
||||||
@@ -37,4 +39,59 @@ final class Brewery extends Building
|
|||||||
$buildingRequirements
|
$buildingRequirements
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the passed village has enough resources to start a beer fest
|
||||||
|
*
|
||||||
|
* @param Village $village
|
||||||
|
* @return array Returns the needed resources (with the right keys) to start a beer fest
|
||||||
|
*/
|
||||||
|
public function checkEnoughBeerFestResources(Village $village): array
|
||||||
|
{
|
||||||
|
// Initialize
|
||||||
|
$neededResources = [];
|
||||||
|
|
||||||
|
// Check the resources quantity
|
||||||
|
foreach (BeerFest::NEEDED_RESOURCES as $key => $value) {
|
||||||
|
// Set the new key
|
||||||
|
$newKey = array_keys($village->getResources())[$key];
|
||||||
|
|
||||||
|
// Check if the resource isn't enough
|
||||||
|
if ($village->getResources()[$newKey] < BeerFest::NEEDED_RESOURCES[$key]) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the resource
|
||||||
|
$neededResources[$newKey] = -BeerFest::NEEDED_RESOURCES[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $neededResources;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a beerfest
|
||||||
|
*
|
||||||
|
* @param Village $village
|
||||||
|
*/
|
||||||
|
public function startBeerFest(Village $village)
|
||||||
|
{
|
||||||
|
// Check if the beer fest hasn't already been started
|
||||||
|
if ($village->owner->isBeerFestActive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Initialize
|
||||||
|
$neededResources = $this->checkEnoughBeerFestResources($village);
|
||||||
|
|
||||||
|
// Check if the beer fest can be started
|
||||||
|
if (empty($neededResources)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the beerFest
|
||||||
|
(new BeerFest($this->getDatabase(), $village->owner))->start();
|
||||||
|
|
||||||
|
// Remove the resources from the village
|
||||||
|
$village->updateResources($neededResources);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -155,7 +155,12 @@ final class RallyPoint extends Building
|
|||||||
* {@inheritdoc}
|
* {@inheritdoc}
|
||||||
* @see \TravianZ\Entity\Building::getBonus()
|
* @see \TravianZ\Entity\Building::getBonus()
|
||||||
*/
|
*/
|
||||||
public function getBonus(){
|
public function getBonus(int $level = 0){
|
||||||
|
// Check if a level has been defined
|
||||||
|
if ($level > 0) {
|
||||||
|
return $this->bonus[$level];
|
||||||
|
}
|
||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
$bonus = [];
|
$bonus = [];
|
||||||
|
|
||||||
@@ -841,7 +846,7 @@ final class RallyPoint extends Building
|
|||||||
|
|
||||||
// Check if it's a normal attack and there is atleast one catapult
|
// Check if it's a normal attack and there is atleast one catapult
|
||||||
if ($parameters['c'] == MovementEnums::NORMAL && $parameters['units'][8] > 0) {
|
if ($parameters['c'] == MovementEnums::NORMAL && $parameters['units'][8] > 0) {
|
||||||
$catapultTargets = $this->getBonus();
|
$catapultTargets = $this->getBonus($village->owner->isBeerFestActive() ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the buildings
|
// Set the buildings
|
||||||
@@ -849,7 +854,7 @@ final class RallyPoint extends Building
|
|||||||
foreach ($targets as $buildingID) {
|
foreach ($targets as $buildingID) {
|
||||||
$building = BuildingsFactory::newBuilding($buildingID, 0, 0);
|
$building = BuildingsFactory::newBuilding($buildingID, 0, 0);
|
||||||
$catapultTarget['id'] = $building->id;
|
$catapultTarget['id'] = $building->id;
|
||||||
$catapultTarget['name'] = $building->name;
|
$catapultTarget['name'] = $buildingID == BuildingEnums::EMPTY ? RANDOM : $building->name;
|
||||||
$catapultTargetBuildings[$type][] = $catapultTarget;
|
$catapultTargetBuildings[$type][] = $catapultTarget;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -980,27 +985,32 @@ final class RallyPoint extends Building
|
|||||||
|
|
||||||
// Initialize
|
// Initialize
|
||||||
$validTargets = 0;
|
$validTargets = 0;
|
||||||
|
|
||||||
// Check the catapult targets correctness
|
// Check the catapult targets correctness
|
||||||
foreach ($this->getBonus() as $validCatapultTargets) {
|
foreach ($this->getBonus($village->owner->isBeerFestActive() ? 1 : 0) as $validCatapultTargets) {
|
||||||
foreach ($validCatapultTargets as $buildingID) {
|
foreach ($validCatapultTargets as $buildingID) {
|
||||||
// Check if the selected targets are on the list
|
// Check if the selected targets are on the list
|
||||||
if (
|
if ($parameters['ctar1'] == $buildingID) {
|
||||||
($parameters['ctar1'] == BuildingEnums::EMPTY ||
|
|
||||||
$parameters['ctar1'] == $buildingID) ||
|
|
||||||
($parameters['ctar2'] == BuildingEnums::EMPTY ||
|
|
||||||
$parameters['ctar2'] == -1 ||
|
|
||||||
$parameters['ctar2'] == $buildingID)
|
|
||||||
) {
|
|
||||||
$validTargets++;
|
$validTargets++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check if the selected targets are on the list
|
||||||
|
// and if there are more than 20 catapults, in case of double target
|
||||||
|
if (
|
||||||
|
($parameters['ctar2'] ?? - 1) == -1 ||
|
||||||
|
($parameters['ctar2'] == $buildingID &&
|
||||||
|
$preparedUnits['units'][8] >= 20)
|
||||||
|
) {
|
||||||
|
$validTargets++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// If all targets are valid, break the for
|
||||||
if ($validTargets == 2) {
|
if ($validTargets == 2) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if the selected targets are valid
|
// Check if the selected targets are valid
|
||||||
if ($validTargets < 2) {
|
if ($validTargets < 2) {
|
||||||
return [];
|
return [];
|
||||||
@@ -1024,7 +1034,7 @@ final class RallyPoint extends Building
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set the hero if present
|
// Set the hero if present
|
||||||
if ($parameters['units'][11] > 0) {
|
if ($preparedUnits['units'][11] > 0) {
|
||||||
$units[$i] = $village->getUnits()[11];
|
$units[$i] = $village->getUnits()[11];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,7 +101,7 @@ abstract class Attack extends Movement
|
|||||||
$this->units[10]->amount ?? 0,
|
$this->units[10]->amount ?? 0,
|
||||||
$this->units[11]->amount ?? 0,
|
$this->units[11]->amount ?? 0,
|
||||||
$this->catapultTargets[0] ?? 0,
|
$this->catapultTargets[0] ?? 0,
|
||||||
$this->catapultTargets[1] ?? 0,
|
$this->catapultTargets[1] ?? -1,
|
||||||
$this->spy ?? 0
|
$this->spy ?? 0
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/*
|
||||||
|
* This file is part of the TravianZ Project
|
||||||
|
*
|
||||||
|
* Source code: <https://github.com/Shadowss/TravianZ/>
|
||||||
|
*
|
||||||
|
* Author: iopietro <https://github.com/iopietro>
|
||||||
|
*
|
||||||
|
* License: GNU GPL-3.0 <https://github.com/Shadowss/TravianZ/blob/master/LICENSE>
|
||||||
|
*
|
||||||
|
* Copyright 2010-2018 TravianZ Team
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace TravianZ\Entity;
|
||||||
|
|
||||||
|
use TravianZ\Database\IDbConnection;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author iopietro
|
||||||
|
*/
|
||||||
|
class BeerFest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var int The base duration of a beer fest (3 days)
|
||||||
|
*/
|
||||||
|
const BASE_DURATION = 259200;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int The needed resources to start a beer fest
|
||||||
|
*/
|
||||||
|
const NEEDED_RESOURCES = [3870, 1680, 215, 10900];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var User The beerFest owner
|
||||||
|
*/
|
||||||
|
public $owner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var IDbConnection
|
||||||
|
*/
|
||||||
|
private $db;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
IDbConnection $db,
|
||||||
|
User $owner
|
||||||
|
) {
|
||||||
|
$this->db = $db;
|
||||||
|
$this->owner = $owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a beerfest
|
||||||
|
*/
|
||||||
|
public function start()
|
||||||
|
{
|
||||||
|
// Set the new beer fest time and update it on the database
|
||||||
|
$this->owner->setBeerFestEndTime(time() + self::BASE_DURATION);
|
||||||
|
$this->owner->setUserFields(['beerfest'], [$this->owner->getBeerFestEndTime()]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the total needed resources
|
||||||
|
*
|
||||||
|
* @return int Returns the total needed resources
|
||||||
|
*/
|
||||||
|
public function getTotalNeededResources(): int
|
||||||
|
{
|
||||||
|
return array_sum(self::NEEDED_RESOURCES);
|
||||||
|
}
|
||||||
|
}
|
||||||
+36
-2
@@ -127,6 +127,11 @@ class User
|
|||||||
*/
|
*/
|
||||||
public $selectedVillage;
|
public $selectedVillage;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int The beer fest end time
|
||||||
|
*/
|
||||||
|
private $beerFestTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var bool Determines if the User has enabled the vacation mode.
|
* @var bool Determines if the User has enabled the vacation mode.
|
||||||
*/
|
*/
|
||||||
@@ -297,8 +302,6 @@ class User
|
|||||||
$this->access = $res['access'];
|
$this->access = $res['access'];
|
||||||
$this->beginnerProtectionEndTime = $res['protect'];
|
$this->beginnerProtectionEndTime = $res['protect'];
|
||||||
$this->ok = $res['ok'];
|
$this->ok = $res['ok'];
|
||||||
$this->vacationModeEnabled = $res['vac_mode'];
|
|
||||||
$this->vacationTime = $res['vac_time'];
|
|
||||||
$this->questNumber = $res['quest'];
|
$this->questNumber = $res['quest'];
|
||||||
$this->maxEvasion = $res['maxevasion'];
|
$this->maxEvasion = $res['maxevasion'];
|
||||||
$this->selectedVillage = $res['actualvillage'];
|
$this->selectedVillage = $res['actualvillage'];
|
||||||
@@ -306,6 +309,9 @@ class User
|
|||||||
// Set private properties
|
// Set private properties
|
||||||
$this->sitters = [$res['sit1'], $res['sit2']];
|
$this->sitters = [$res['sit1'], $res['sit2']];
|
||||||
$this->password = $res['password'];
|
$this->password = $res['password'];
|
||||||
|
$this->beerFestTime = $res['beerfest'];
|
||||||
|
$this->vacationModeEnabled = $res['vac_mode'];
|
||||||
|
$this->vacationTime = $res['vac_time'];
|
||||||
|
|
||||||
// Set the User's villages
|
// Set the User's villages
|
||||||
$this->setVillages();
|
$this->setVillages();
|
||||||
@@ -351,6 +357,34 @@ class User
|
|||||||
return $this->vacationModeEnabled && $this->vacationTime > time();
|
return $this->vacationModeEnabled && $this->vacationTime > time();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the user is on vacation
|
||||||
|
*
|
||||||
|
* @return bool Returns true if the User is on vaction, false otherwise
|
||||||
|
*/
|
||||||
|
public function isBeerFestActive(): bool
|
||||||
|
{
|
||||||
|
return $this->beerFestTime > time();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the beer fest end time
|
||||||
|
*
|
||||||
|
* @return bool Returns the beer fest end time
|
||||||
|
*/
|
||||||
|
public function getBeerFestEndTime(): int
|
||||||
|
{
|
||||||
|
return $this->beerFestTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set the beer fest end time
|
||||||
|
*/
|
||||||
|
public function setBeerFestEndTime(int $newTime)
|
||||||
|
{
|
||||||
|
$this->beerFestTime = $newTime;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the user started the account deletion process
|
* Check if the user started the account deletion process
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -195,16 +195,21 @@ abstract class BuildingsFactory
|
|||||||
return array_combine(range(0, 20), range(100, 300, 10));
|
return array_combine(range(0, 20), range(100, 300, 10));
|
||||||
case BuildingEnums::RALLY_POINT:
|
case BuildingEnums::RALLY_POINT:
|
||||||
return [
|
return [
|
||||||
1 => [],
|
1 => [
|
||||||
|
0 =>
|
||||||
|
[
|
||||||
|
BuildingEnums::EMPTY
|
||||||
|
]
|
||||||
|
],
|
||||||
3 => [
|
3 => [
|
||||||
2 =>
|
3 =>
|
||||||
[
|
[
|
||||||
BuildingEnums::WAREHOUSE,
|
BuildingEnums::WAREHOUSE,
|
||||||
BuildingEnums::GRANARY
|
BuildingEnums::GRANARY
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
5 => [
|
5 => [
|
||||||
0 =>
|
1 =>
|
||||||
[
|
[
|
||||||
BuildingEnums::WOODCUTTER,
|
BuildingEnums::WOODCUTTER,
|
||||||
BuildingEnums::CLAY_PIT,
|
BuildingEnums::CLAY_PIT,
|
||||||
@@ -218,7 +223,7 @@ abstract class BuildingsFactory
|
|||||||
]
|
]
|
||||||
],
|
],
|
||||||
10 => [
|
10 => [
|
||||||
1 =>
|
2 =>
|
||||||
[
|
[
|
||||||
BuildingEnums::ACADEMY,
|
BuildingEnums::ACADEMY,
|
||||||
BuildingEnums::BARRACKS,
|
BuildingEnums::BARRACKS,
|
||||||
@@ -234,7 +239,7 @@ abstract class BuildingsFactory
|
|||||||
BuildingEnums::TOURNAMENT_SQUARE
|
BuildingEnums::TOURNAMENT_SQUARE
|
||||||
],
|
],
|
||||||
|
|
||||||
2 =>
|
3 =>
|
||||||
[
|
[
|
||||||
2 => BuildingEnums::BREWERY,
|
2 => BuildingEnums::BREWERY,
|
||||||
BuildingEnums::EMBASSY,
|
BuildingEnums::EMBASSY,
|
||||||
|
|||||||
@@ -686,6 +686,10 @@ define("PASSWORD_SENT", "If the email address exists, a new password has been se
|
|||||||
define("PASSWORD_SET_SUCCESS", "The password was set successfully.");
|
define("PASSWORD_SET_SUCCESS", "The password was set successfully.");
|
||||||
define("NEW_PASSWORD_ERROR", "Invalid code, password or the password has already been set.");
|
define("NEW_PASSWORD_ERROR", "Invalid code, password or the password has already been set.");
|
||||||
|
|
||||||
|
//BEER FEST
|
||||||
|
define("BEER_FEST","Beer fest");
|
||||||
|
define("CELEBRATION","Celebration");
|
||||||
|
|
||||||
//ATTACKS ETC.
|
//ATTACKS ETC.
|
||||||
define("TROOP_MOVEMENTS","Troop Movements:");
|
define("TROOP_MOVEMENTS","Troop Movements:");
|
||||||
define("ARRIVING_REINF_TROOPS","Arriving reinforcing troops");
|
define("ARRIVING_REINF_TROOPS","Arriving reinforcing troops");
|
||||||
|
|||||||
@@ -38,6 +38,8 @@ use TravianZ\Exceptions\InvalidParametersException;
|
|||||||
use TravianZ\Factory\BuildingsFactory;
|
use TravianZ\Factory\BuildingsFactory;
|
||||||
use TravianZ\Mvc\Model;
|
use TravianZ\Mvc\Model;
|
||||||
use TravianZ\Utils\Generator;
|
use TravianZ\Utils\Generator;
|
||||||
|
use TravianZ\Data\Buildings\Brewery;
|
||||||
|
use TravianZ\Entity\BeerFest;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author iopietro
|
* @author iopietro
|
||||||
@@ -879,4 +881,33 @@ class BuildingModel extends Model
|
|||||||
['villageFarmLists' => $farmLists]
|
['villageFarmLists' => $farmLists]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Manage the brewery
|
||||||
|
*
|
||||||
|
* @param Brewery $building
|
||||||
|
* @param Village $village
|
||||||
|
* @param array $parameters
|
||||||
|
*/
|
||||||
|
public function manageBrewery(Brewery $building, Village $village, array $parameters)
|
||||||
|
{
|
||||||
|
// Check if there's an action to execute
|
||||||
|
// TODO: Don't repeat it every time
|
||||||
|
if (isset($parameters['POST']['action'])) {
|
||||||
|
$action = $parameters['POST']['action'];
|
||||||
|
if (method_exists($building, $action)) {
|
||||||
|
$results = $building->$action($village, $parameters['POST']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return [
|
||||||
|
'beerFest' => [
|
||||||
|
'neededResources' => BeerFest::NEEDED_RESOURCES,
|
||||||
|
'duration' => Generator::getTimeFormat(BeerFest::BASE_DURATION),
|
||||||
|
'error' => $village->owner->isBeerFestActive() ?
|
||||||
|
Generator::getTimeFormat($village->owner->getBeerFestEndTime() - $this->time) :
|
||||||
|
(empty($building->checkEnoughBeerFestResources($village)) ? TOO_FEW_RESOURCES : '')
|
||||||
|
]
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,13 +69,11 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th>{$smarty.const.DESTINATION}:</th>
|
<th>{$smarty.const.DESTINATION}:</th>
|
||||||
<td colspan="{$colspan}">
|
<td colspan="{$colspan}">
|
||||||
{$targetName = 'ctar1'}
|
{$targetType = 1}
|
||||||
{$randomTargetValue = 0}
|
|
||||||
{include file=$smarty.const.TEMPLATES_DIR|cat:'sendUnits/catapultTargets.tpl'}
|
{include file=$smarty.const.TEMPLATES_DIR|cat:'sendUnits/catapultTargets.tpl'}
|
||||||
|
|
||||||
{if $units[8] >= 20}
|
{if $units[8] >= 20}
|
||||||
{$targetName = 'ctar2'}
|
{$targetType = 2}
|
||||||
{$randomTargetValue = -1}
|
|
||||||
{include file=$smarty.const.TEMPLATES_DIR|cat:'sendUnits/catapultTargets.tpl'}
|
{include file=$smarty.const.TEMPLATES_DIR|cat:'sendUnits/catapultTargets.tpl'}
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@@ -1,10 +1,16 @@
|
|||||||
{$groupNames = [$smarty.const.RESOURCES, $smarty.const.INFRASTRUCTURE, $smarty.const.MILITARY]}
|
{$groupNames = [1 => $smarty.const.RESOURCES, $smarty.const.INFRASTRUCTURE, $smarty.const.MILITARY]}
|
||||||
|
|
||||||
<select name="{$targetName}" class="dropdown">
|
<select name="ctar{$targetType}" class="dropdown">
|
||||||
{if $randomTargetValue < 0}
|
{if $targetType > 1}
|
||||||
<option value="{$randomTargetValue + 1}">-</option>
|
<option value="-1">-</option>
|
||||||
{/if}
|
{/if}
|
||||||
<option value="{$randomTargetValue}">{$smarty.const.RANDOM}</option>
|
|
||||||
|
{if !empty($catapultTargetBuildings[0])}
|
||||||
|
{foreach $catapultTargetBuildings[0] as $building}
|
||||||
|
<option value="{$building.id}">{$building.name}</option>
|
||||||
|
{/foreach}
|
||||||
|
{/if}
|
||||||
|
|
||||||
{foreach $groupNames as $type => $groupName}
|
{foreach $groupNames as $type => $groupName}
|
||||||
{if !empty($catapultTargetBuildings[$type])}
|
{if !empty($catapultTargetBuildings[$type])}
|
||||||
<optgroup label="{$groupName}">
|
<optgroup label="{$groupName}">
|
||||||
@@ -14,4 +20,4 @@
|
|||||||
</optgroup>
|
</optgroup>
|
||||||
{/if}
|
{/if}
|
||||||
{/foreach}
|
{/foreach}
|
||||||
</select>
|
</select>
|
||||||
|
|||||||
@@ -1,2 +1,4 @@
|
|||||||
{assign var=bonusTexts value=[$smarty.const.CURRENT_BONUS, $smarty.const.BONUS_LEVEL, $smarty.const.PERCENT]}
|
{assign var=bonusTexts value=[$smarty.const.CURRENT_BONUS, $smarty.const.BONUS_LEVEL, $smarty.const.PERCENT]}
|
||||||
{include file={$smarty.const.TEMPLATES_DIR}|cat:'village/buildings/showBonus.tpl'}
|
{include file={$smarty.const.TEMPLATES_DIR}|cat:'village/buildings/showBonus.tpl'}
|
||||||
|
<br />
|
||||||
|
{include file={$smarty.const.TEMPLATES_DIR}|cat:'village/buildings/brewery/beerFest.tpl'}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
<form action="build.php?id={$parameters['id']}" method="post" id="start">
|
||||||
|
<input type="hidden" name="action" value="startBeerFest">
|
||||||
|
<table cellpadding="1" cellspacing="1" class="build_details">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<td>{$smarty.const.CELEBRATION}</td>
|
||||||
|
<td>{$smarty.const.ACTION}</td>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="desc">
|
||||||
|
<div class="tit">
|
||||||
|
<a href="#" onClick="return Popup(0, 1);">{$smarty.const.BEER_FEST}</a>
|
||||||
|
</div>
|
||||||
|
<div class="details">
|
||||||
|
<img class="r1" src="assets/img/x.gif" alt="{$smarty.const.LUMBER}" title="{$smarty.const.LUMBER}" />{$beerFest['neededResources'][0]}|
|
||||||
|
<img class="r2" src="assets/img/x.gif" alt="{$smarty.const.CLAY}" title="{$smarty.const.CLAY}" />{$beerFest['neededResources'][1]}|
|
||||||
|
<img class="r3" src="assets/img/x.gif" alt="{$smarty.const.IRON}" title="{$smarty.const.IRON}" />{$beerFest['neededResources'][2]}|
|
||||||
|
<img class="r4" src="assets/img/x.gif" alt="{$smarty.const.CROP}" title="{$smarty.const.CROP}" />{$beerFest['neededResources'][3]}|
|
||||||
|
<img class="clock" src="assets/img/x.gif" alt="{$smarty.const.DURATION}" title="{$smarty.const.DURATION}" />{$beerFest.duration}
|
||||||
|
|
||||||
|
{if $gold >= 3 && $isMarketplaceBuilt && $villageTotalResources >= $beerFest['totalResources']} |
|
||||||
|
<a href="build.php?gid=17&t=3&r1={$beerFest['neededResources'][0]}&r2={$beerFest['neededResources'][1]}&r3={$beerFest['neededResources'][2]}&r4={$beerFest['neededResources'][3]}">
|
||||||
|
<img class="npc" src="assets/img/x.gif"alt="{$smarty.const.NPC_TRADE}" title="{$smarty.const.NPC_TRADE}" />
|
||||||
|
</a>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
{if !empty($beerFest.error)}
|
||||||
|
<td class="{if $beerFest.error|strstr:':'}timer{else}none{/if}">{$beerFest.error}</td>
|
||||||
|
{else}
|
||||||
|
<td class="act">
|
||||||
|
<a class="research" href="#" onclick="document.getElementById('start').submit();">{$smarty.const.START}</a>
|
||||||
|
</td>
|
||||||
|
{/if}
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
<td class="none">{$research.error}</td>
|
<td class="none">{$research.error}</td>
|
||||||
{else}
|
{else}
|
||||||
<td class="act">
|
<td class="act">
|
||||||
<a class="research" href="build.php?id={$parameters['id']}&a={$unit}&c={$sessionChecker}">{$smarty.const.RESEARCH}</a>
|
<a class="research" href="build.php?id={$parameters['id']}&a={$unit}&c={$sessionChecker}">{$smarty.const.RESEARCH}</a>
|
||||||
</td>
|
</td>
|
||||||
{/if}
|
{/if}
|
||||||
</tr>
|
</tr>
|
||||||
|
|||||||
+715
-1285
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user