diff --git a/cypress/e2e/fight.cy.js b/cypress/e2e/fight.cy.js
new file mode 100644
index 000000000..fd639e75b
--- /dev/null
+++ b/cypress/e2e/fight.cy.js
@@ -0,0 +1,35 @@
+/* eslint-disable semi */
+///
+// eslint-disable-next-line no-unused-vars
+/* global cy Cypress describe beforeEach afterEach it */
+
+// getting started guide:
+// https://on.cypress.io/introduction-to-cypress
+
+describe('fight', () => {
+ beforeEach(() => {
+ cy.standardLogin()
+ })
+ afterEach(() => {
+ })
+
+ it('displays someone to fight', () => {
+ cy.visit('/enemies')
+ cy.contains('Fight')
+ cy.url().should('match', /enemies$/u)
+ cy.get('[role=heading]').contains('Fight').should('be.visible')
+ cy.contains('Attack').should('be.visible')
+ cy.get('.avatar').should('be.visible')
+ })
+
+ // NPC checks
+ it('can attack a thief', () => {
+ cy.visit('/enemies')
+ cy.url().should('match', /enemies$/u)
+ cy.get('[role=heading]').contains('Fight').should('be.visible')
+ cy.contains('Attack a').should('be.visible')
+ cy.get('a[href*="/npc/attack/thief"]').first().click()
+ cy.contains('sees you and prepares to defend!').should('be.visible')
+ // Hmm, will fail on random group of thieves
+ })
+});
diff --git a/cypress/e2e/map.cy.js b/cypress/e2e/map.cy.js
new file mode 100644
index 000000000..bb3d8a7dc
--- /dev/null
+++ b/cypress/e2e/map.cy.js
@@ -0,0 +1,38 @@
+/* eslint-disable semi */
+///
+// eslint-disable-next-line no-unused-vars
+/* global cy Cypress describe beforeEach afterEach it */
+
+// getting started guide:
+// https://on.cypress.io/introduction-to-cypress
+
+describe('check map loads', () => {
+ beforeEach(() => {
+ cy.standardLogin()
+ })
+ afterEach(() => {
+ })
+
+ it('displays map doshin', () => {
+ cy.visit('/map')
+ cy.contains('Map')
+ cy.url().should('match', /map$/u)
+ cy.get('[role=heading]').should('be.visible')
+ cy.contains('Map').should('be.visible')
+ cy.contains('Doshin').should('be.visible')
+ cy.contains('Shrine').should('be.visible')
+ cy.contains('Village Square').should('be.visible')
+ })
+
+ // it('displays the map even for logged out users', () => {
+ // cy.logout()
+ // cy.visit('/map')
+ // cy.contains('Map')
+ // cy.url().should('match', /map$/u)
+ // cy.get('[role=heading]').should('be.visible')
+ // cy.contains('Map').should('be.visible')
+ // cy.contains('Doshin').should('be.visible')
+ // cy.contains('Shrine').should('be.visible')
+ // cy.contains('Village Square').should('be.visible')
+ // })
+});
diff --git a/cypress/e2e/signup.cy.js b/cypress/e2e/signup.cy.js
index 28ca72620..1d62216cb 100644
--- a/cypress/e2e/signup.cy.js
+++ b/cypress/e2e/signup.cy.js
@@ -39,7 +39,7 @@ describe('signup a new ninja', () => {
cy.get('input[type=email]').type(`ninjawarstchalvak+cypress-testing${random}@gmail.com`)
cy.get('input[type=password]').first().type(Cypress.env('TEST_PASSWORD'), { log: false })
cy.get('input[type=password][name=cpass]').type(Cypress.env('TEST_PASSWORD'), { log: false })
- cy.get('input[name=send_name]').type(`cypress-test-user${random}`)
+ cy.get('input[name=send_name]').type(`Viper-${random}`)
cy.get('input[type=submit]').click()
cy.get('[role=alert]').should('not.exist')
cy.contains('You are almost ready to be a ninja!').should('be.visible')
diff --git a/cypress/e2e/skills.cy.js b/cypress/e2e/skills.cy.js
new file mode 100644
index 000000000..1559ee93b
--- /dev/null
+++ b/cypress/e2e/skills.cy.js
@@ -0,0 +1,24 @@
+/* eslint-disable semi */
+///
+// eslint-disable-next-line no-unused-vars
+/* global cy Cypress describe beforeEach afterEach it */
+
+// getting started guide:
+// https://on.cypress.io/introduction-to-cypress
+
+describe('check skills for current ninja', () => {
+ beforeEach(() => {
+ cy.standardLogin()
+ })
+ afterEach(() => {
+ })
+
+ it('displays skills', () => {
+ cy.visit('/skill')
+ cy.contains('Skills')
+ cy.url().should('match', /skill$/u)
+ cy.get('[role=heading]').contains('Skills').should('be.visible')
+ cy.contains('Dueling Combat Skills').should('be.visible')
+ cy.contains('Passive Skills').should('be.visible')
+ })
+});
diff --git a/cypress/support/commands.js b/cypress/support/commands.js
index dc13f26c7..560444cdb 100644
--- a/cypress/support/commands.js
+++ b/cypress/support/commands.js
@@ -46,6 +46,15 @@ Cypress.Commands.add('standardLogin', () => {
)
})
+Cypress.Commands.add('logout', () => {
+ cy.visit('/logout')
+ // wait for the url to not be logout
+ cy.log('After logout it should redirect');
+ cy.url().should('include', 'loggedout', { timeout: 10000 })
+ cy.log('Cypress logout() command ran')
+ cy.log('========= Logout should now be COMPLETE --RR =======')
+})
+
// -- This is a parent command --
// Cypress.Commands.add('login', (email, password) => { ... })
//
diff --git a/deploy/lib/control/NpcController.php b/deploy/lib/control/NpcController.php
index 57dcc25b7..2b6298d84 100644
--- a/deploy/lib/control/NpcController.php
+++ b/deploy/lib/control/NpcController.php
@@ -164,7 +164,8 @@ private function attackAbstractNpc(string $victim, Player $player, array $npcs):
$reward_item = (isset($npc_stats['item']) && $npc_stats['item'] ? $npc_stats['item'] : null);
$is_quick = (bool) ($npco->getSpeed() > $player->getSpeed()); // Beyond basic speed and they see you coming, so show that message.
$is_weaker = ($npco->getStrength() * 3) < $player->getStrength(); // Npc much weaker?
- $is_stronger = ($npco->getStrength()) > ($player->getStrength() * 3); // Npc More than twice as strong?
+ $enemy_strength = $npco->getStrength();
+ $much_stronger = ($npco->getStrength()) > ($player->getStrength() * 3); // Npc much stronger?
$image = $npc_stats['img'] ?? $npc_stats['full_img'] ?? null;
// Assume defeat...
$victory = false;
@@ -185,9 +186,10 @@ private function attackAbstractNpc(string $victim, Player $player, array $npcs):
$npc_damage = $npco->damage();
$ninja_damage = $player->damage();
$npc_damage_class = Combat::determineDamageClass($npc_damage, $player->health);
- $ninja_damage_class = Combat::determineDamageClass($ninja_damage, $npco->getHealth());
+ $npc_health = $npco->getHealth();
+ $ninja_damage_class = Combat::determineDamageClass($ninja_damage, $npc_health);
$survive_fight = $player->harm($npc_damage);
- $kill_npc = ($npco->getHealth() <= $ninja_damage);
+ $kill_npc = ($npc_health <= $ninja_damage);
if ($survive_fight > 0) {
// The ninja survived, they get any gold the npc has.
@@ -200,8 +202,9 @@ private function attackAbstractNpc(string $victim, Player $player, array $npcs):
// Victory occurred, reward the poor sap.
if ($npco->inventory()) {
$inventory = new Inventory($player);
+ $npc_inventory = array_keys($npco->inventory());
- foreach (array_keys($npco->inventory()) as $l_item) {
+ foreach ($npc_inventory as $l_item) {
$item = Item::findByIdentity($l_item);
$received_items[] = $item->getName();
$inventory->add($item->identity(), 1);
@@ -244,7 +247,9 @@ private function attackAbstractNpc(string $victim, Player $player, array $npcs):
'victory' => $victory,
'survive_fight' => $survive_fight,
'ninja_damage' => $ninja_damage,
+ 'npc_damage' => $npc_damage,
'npc_damage_class' => $npc_damage_class,
+ 'npc_health' => $npc_health,
'ninja_damage_class' => $ninja_damage_class,
'kill_npc' => $kill_npc,
'image_path' => $image_path,
@@ -255,7 +260,9 @@ private function attackAbstractNpc(string $victim, Player $player, array $npcs):
'is_villager' => $npco->hasTrait('villager'),
'race' => $npco->race(),
'is_weaker' => $is_weaker,
- 'is_stronger' => $is_stronger,
+ 'much_stronger' => $much_stronger,
+ 'enemy_strength' => $enemy_strength,
+ 'tagline' => $npco->tagline(),
]
];
}
diff --git a/deploy/lib/data/Npc.php b/deploy/lib/data/Npc.php
index b4d1c1bca..a70783796 100644
--- a/deploy/lib/data/Npc.php
+++ b/deploy/lib/data/Npc.php
@@ -31,6 +31,7 @@ class Npc implements Character
public $race;
public $gold;
public $bounty_mod;
+ public $tagline;
public function __construct($content)
{
@@ -284,4 +285,14 @@ public function minGold()
{
return (int) ($this->hasTrait('rich') ? floor($this->gold()/self::RICH_MIN_GOLD_DIVISOR) : self::MIN_GOLD);
}
+
+ /**
+ * Any tagline they get
+ *
+ * @return string
+ */
+ public function tagline()
+ {
+ return $this->tagline;
+ }
}
diff --git a/deploy/lib/data/NpcFactory.php b/deploy/lib/data/NpcFactory.php
index 5041e615e..b7b36e836 100644
--- a/deploy/lib/data/NpcFactory.php
+++ b/deploy/lib/data/NpcFactory.php
@@ -72,6 +72,7 @@ public static function fleshOutFromData($data, $npc)
$npc->gold = @$data['gold'];
$npc->traits_array = (isset($data['traits']) && is_array($data['traits']) ? $data['traits'] : []);
$npc->inventory = null; // The actual instance inventory is intitially just null;
+ $npc->tagline = @$data['tagline'];
}
/**
diff --git a/deploy/npc-list.php b/deploy/npc-list.php
index 8ff457cf4..5ebbc759c 100644
--- a/deploy/npc-list.php
+++ b/deploy/npc-list.php
@@ -2,6 +2,10 @@
use NinjaWars\core\data\NpcFactory;
+/**
+ * Note that 1+stamina*5 is health, plus 2*stamina if armored.
+ */
+
// Npc matrix planning document: https://docs.google.com/spreadsheet/ccc?key=0AkoUgtBBP00HdGZ1eUhaekhTb1dnZVh3ZlpoRExWdGc#gid=0
NpcFactory::$data = [
'firefly' => [ // Baseline weakest mob
@@ -131,13 +135,14 @@
],
'thief2' => [
'name' => 'Thief',
- 'strength' => 17,
+ 'strength' => 16,
'stamina' => 10,
- 'speed' => 10,
+ 'speed' => 11,
'race' => 'human',
'img' => 'thief.png',
'inventory' => [
- 'shuriken' => '0.9',
+ 'shuriken' => '.9',
+ 'shell' => '1',
],
'gold' => 40,
@@ -147,6 +152,7 @@
'gang',
'defender',
],
+ 'tagline' => 'Beware the Ninja Thieves, they have entered this world to steal from all!',
],
'peasant2' => [
'name' => 'Peasant',
@@ -172,7 +178,7 @@
'name' => 'Merchant',
'race' => 'human',
'strength' => 10,
- 'stamina' => 20,
+ 'stamina' => 15,
'speed' => 10,
'ki' => 1,
'damage' => 15,
@@ -268,6 +274,9 @@
'escaper',
'flying',
],
+ 'inventory' => [
+ 'egg' => '.3',
+ ],
],
] + (
!defined('DEBUG') || !DEBUG ? [] :
@@ -277,6 +286,7 @@
'short' => 'swarms and buzzes through the air',
'strength' => 13,
'speed' => 30,
+ 'stamina' => 4,
'damage' => 6,
'gold' => 0,
'race' => 'insect',
diff --git a/deploy/sql/migrations/2023-10-06-add-some-items.sql b/deploy/sql/migrations/2023-10-06-add-some-items.sql
new file mode 100644
index 000000000..79a7dbc02
--- /dev/null
+++ b/deploy/sql/migrations/2023-10-06-add-some-items.sql
@@ -0,0 +1,19 @@
+insert into item (
+item_internal_name,
+item_display_name,
+item_cost,
+image,
+for_sale,
+ usage, ignore_stealth, covert, turn_cost, target_damage,
+ turn_change, self_use, plural, other_usable, traits
+)
+values
+(
+'egg',
+'Egg',
+1,
+'',
+default,
+ 'The egg of some creature', default, default, default, default,
+ default, default, 's', default, 'food'
+);
diff --git a/deploy/templates/fight.tpl b/deploy/templates/fight.tpl
index 2b5f9dcaf..a0c405080 100644
--- a/deploy/templates/fight.tpl
+++ b/deploy/templates/fight.tpl
@@ -1,4 +1,4 @@
-
Fight
+Fight
diff --git a/deploy/templates/map.tpl b/deploy/templates/map.tpl
index 23524cf57..25d04bc9e 100644
--- a/deploy/templates/map.tpl
+++ b/deploy/templates/map.tpl
@@ -1,4 +1,4 @@
-Map
+Map
@@ -30,4 +30,4 @@
{/if}
-
\ No newline at end of file
+
diff --git a/deploy/templates/npc.abstract.tpl b/deploy/templates/npc.abstract.tpl
index 8cb79245f..5cffda598 100644
--- a/deploy/templates/npc.abstract.tpl
+++ b/deploy/templates/npc.abstract.tpl
@@ -74,7 +74,7 @@ article#fight nav{
{if $is_quick or $npco->hasTrait('defender')}
The {$race|escape} sees you and prepares to defend!
{/if}
- {if $is_stronger}
+ {if $much_stronger}
The {$race|escape} seems stronger than you!
{/if}
@@ -116,18 +116,23 @@ article#fight nav{
{if $is_weaker}
The {$display_name|escape} flees from you and escapes!
{else}
- {if $is_stronger}
- You are unable to kill the {$display_name|escape}, so you escape instead!
+ {if $much_stronger}
+ You are unable to end the {$display_name|escape}, so you escape instead!
{else}
- You fight to a standstill and neither wins.
+ You fight to a standstill and neither wins.
{/if}
{/if}
+ {if $tagline}
+ {$tagline}
+ {/if}
{/if}
{if $received_gold}You gather {$received_gold} gold .
{/if}
- {foreach from=$received_display_items item=display_item}You obtained {$display_item} !
{/foreach}
+ {foreach from=$received_display_items item=display_item}
+ You obtained {$display_item} !
+ {/foreach}
diff --git a/deploy/templates/npc.list.tpl b/deploy/templates/npc.list.tpl
index 0335b3b90..a367a5e5c 100644
--- a/deploy/templates/npc.list.tpl
+++ b/deploy/templates/npc.list.tpl
@@ -3,12 +3,12 @@
Attack a:
{foreach name="person" from=$npcs key="idx" item="npc"}
-
+
{/foreach}
{foreach name="creatures" from=$other_npcs key="idx" item="npc"}
-
+
{/foreach}
-
\ No newline at end of file
+
diff --git a/deploy/templates/signup.tpl b/deploy/templates/signup.tpl
index c25e3358f..933611810 100644
--- a/deploy/templates/signup.tpl
+++ b/deploy/templates/signup.tpl
@@ -10,9 +10,9 @@
Your Choices
- Email - {$signupRequest && $signupRequest->enteredEmail|escape}
- Password - {if $signupRequest && $signupRequest->enteredPass}***yourpassword*** {else}NO PASSWORD {/if}
- Ninja Name - {$signupRequest && $signupRequest->enteredName|escape}
+ Email - {if $signupRequest}{$signupRequest->enteredEmail|escape}{/if}
+ Password - {if $signupRequest}{$signupRequest->enteredPass}{/if}***yourpassword*** {else}NO PASSWORD {/if}
+ Ninja Name - {if $signupRequest}{$signupRequest->enteredName|escape}{/if}
Ninja Type - {$class_display|escape}
@@ -39,7 +39,10 @@
{if $confirmed}
Account with the login email "{$signupRequest->enteredEmail|escape}" is now confirmed!
{else}
Phase 5: When you receive an email from ninjawars ({$smarty.const.SYSTEM_EMAIL}), click the confirmation link to activate your account.
diff --git a/deploy/templates/skills.tpl b/deploy/templates/skills.tpl
index 6da4a9466..cd5be7876 100644
--- a/deploy/templates/skills.tpl
+++ b/deploy/templates/skills.tpl
@@ -4,7 +4,7 @@
}
-Skills
+Skills
{include file='flash-message.tpl'}