Skip to content

Commit

Permalink
fixed webtest langs for 2moon
Browse files Browse the repository at this point in the history
  • Loading branch information
jstar88 committed Feb 24, 2015
1 parent a6d8ebc commit cd7d030
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 9 deletions.
5 changes: 3 additions & 2 deletions tests/RunnableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
*/

require (dirname(__DIR__) . DIRECTORY_SEPARATOR ."utils".DIRECTORY_SEPARATOR."includer.php");
require (OPBEPATH . "tests".DIRECTORY_SEPARATOR."LangImplementation.php");
require (OPBEPATH . "tests".DIRECTORY_SEPARATOR."runnable".DIRECTORY_SEPARATOR."langs".DIRECTORY_SEPARATOR."MoonsLangImplementation.php");
require (OPBEPATH . "tests".DIRECTORY_SEPARATOR."runnable".DIRECTORY_SEPARATOR."langs".DIRECTORY_SEPARATOR."XGLangImplementation.php");

class RunnableTest
{
Expand All @@ -45,7 +46,7 @@ public function __construct($debug = false)
}
if(!LangManager::getInstance()->implementationExist())
{
LangManager::getInstance()->setImplementation(new LangImplementation('XG'));
LangManager::getInstance()->setImplementation(new XGLangImplementation());
}
$attackers = $this->getAttachers();
$defenders = $this->getDefenders();
Expand Down
8 changes: 7 additions & 1 deletion tests/runnable/WebTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ private function buildPlayerGroup($tech, $fleets)
$selectedVar = 'XG';
}
WebTest::includeVars($selectedVar);
LangManager::getInstance()->setImplementation(new LangImplementation($selectedVar));
if ($selectedVar == 'XG'){
LangManager::getInstance()->setImplementation(new XGLangImplementation());
}
else{
LangManager::getInstance()->setImplementation(new MoonsLangImplementation());
}


if (isset($_GET['good']))
{
Expand Down
70 changes: 70 additions & 0 deletions tests/runnable/langs/MoonsLangImplementation.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?php

class MoonsLangImplementation implements Lang
{
private $lang;
public function __construct()
{
require (OPBEPATH . "tests/runnable/langs/2Moons_1-3-5.php");
$this->lang = $lang;
}

public function getShipName($id)
{
return $this->lang['tech'][$id];
}
public function getAttackersAttackingDescr($amount, $damage)
{
return "The attacking fleet fires a total of " . $amount . ' times with the power of ' . $damage . " upon the defender.<br />";
}
public function getDefendersDefendingDescr($damage)
{
return "The defender's shields absorb " . $damage . " damage points.<br />";
}
public function getDefendersAttackingDescr($amount, $damage)
{
return "The defending fleet fires a total of " . $amount . ' times with the power of ' . $damage . " upon the attacker.<br />";
}
public function getAttackersDefendingDescr($damage)
{
return "The attacker's shields absorb " . $damage . " damage points.<br />";
}
public function getAttackerHasWon()
{
return "The attacker has won the battle.";
}
public function getDefendersHasWon()
{
return "The defender has won the battle.";
}
public function getDraw()
{
return "The battle ended in a draw.";
}
public function getStoleDescr($metal, $crystal, $deuterium)
{
return "He captured<br> $metal metal, $crystal and $deuterium deuterium.";
}
public function getAttackersLostUnits($units)
{
return "The attacker lost a total of $units units.";
}
public function getDefendersLostUnits($units)
{
return "The defender lost a total of $units units.";
}
public function getFloatingDebris($metal, $crystal)
{
return "At these space coordinates now float $metal metal and $crystal crystal.";
}
public function getMoonProb($prob)
{
return "The probability that a moon emerge from the rubble is $prob% .";
}
public function getNewMoon()
{
return "The huge amount of metal and glass are functioning and form a lunar satellite in orbit the planet.";
}
}

?>
Original file line number Diff line number Diff line change
@@ -1,26 +1,25 @@
<?php

class LangImplementation implements Lang
class XGLangImplementation implements Lang
{
private $lang;
public function __construct($name)
public function __construct()
{
require (OPBEPATH . "tests/runnable/langs/$name.php");
require (OPBEPATH . "tests/runnable/langs/XG.php");
$this->lang = $lang;
}

public function getShipName($id)
{
return isset($this->lang['tech'][$id]) ? $this->lang['tech'][$id] : $id . ' <font color=red>* no lang found</font>';
return $this->lang['tech'][$id];
}

public function getAttackersAttackingDescr($amount, $damage)
{
return $this->lang['fleet_attack_1'] . ' ' . $damage . " " . $this->lang['damage'] . " with $amount shots ";
}
public function getDefendersDefendingDescr($damage)
{
return $this->lang['fleet_attack_2'] . $damage . ' ' . $this->lang['damage'];;
return $this->lang['fleet_attack_2'] . $damage . ' ' . $this->lang['damage'];
}
public function getDefendersAttackingDescr($amount, $damage)
{
Expand Down

0 comments on commit cd7d030

Please sign in to comment.