From cf5613bdaea170b94727033227f73a84481d84a2 Mon Sep 17 00:00:00 2001 From: Coco R Date: Wed, 11 Jun 2025 15:42:10 -0400 Subject: [PATCH 1/5] Bump local dev to php8.3-fpm. --- deploy/conf/nw.local.nginx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/deploy/conf/nw.local.nginx b/deploy/conf/nw.local.nginx index 09971af5b..1ce2434cd 100644 --- a/deploy/conf/nw.local.nginx +++ b/deploy/conf/nw.local.nginx @@ -97,8 +97,8 @@ server { #add_header X-Frame-Options SAMEORIGIN; add_header Content-Security-Policy "default-src * blob: filesystem: about: ws: wss: 'unsafe-eval' 'unsafe-inline'; script-src 'self' https://localhost:8765/ https://www.gstatic.com https://www.google.com https://www.recaptcha.net https://ajax.googleapis.com https://api.github.com https://ws-na.amazon-adsystem.com http://pagead2.googlesyndication.com https://tpc.googlesyndication.com https://www.googleadservices.com https://kit.fontawesome.com https://js.sentry-cdn.com/ https://browser.sentry-cdn.com/ 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * 'self' https://localhost:* https://localhost:8765 http://www.ninjawars.net http://ninjawars.net https://www.ninjawars.net; style-src 'self' https://kit.fontawesome.com https://fonts.gstatic.com https://fonts.googleapis.com data: blob: 'unsafe-inline'; font-src 'self' https://kit.fontawesome.com https://ka-f.fontawesome.com https://fonts.gstatic.com https://fonts.googleapis.com data: blob: 'unsafe-inline'; worker-src 'self' https://localhost:8765/ data: blob: 'unsafe-inline';"; fastcgi_param PHP_VALUE "session.cookie_domain= \n date.timezone=America/New_York \n default_charset=UTF-8 \n session.gc_maxlifetime=144000 \n display_errors=On \n"; - # Check session via: php-fpm8.2 -i | grep session.gc - fastcgi_pass unix:/run/php/php8.2-fpm.sock; + # Check session via: php-fpm8.3 -i | grep session.gc + fastcgi_pass unix:/run/php/php8.3-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root/front-controller.php; include fastcgi_params; } @@ -108,7 +108,7 @@ server { add_header Content-Security-Policy "default-src * blob: filesystem: about: ws: wss: 'unsafe-eval' 'unsafe-inline'; script-src 'self' https://localhost:8765/ https://www.gstatic.com https://www.google.com https://www.recaptcha.net https://ajax.googleapis.com https://api.github.com https://ws-na.amazon-adsystem.com http://pagead2.googlesyndication.com https://tpc.googlesyndication.com https://www.googleadservices.com https://kit.fontawesome.com https://js.sentry-cdn.com/ https://browser.sentry-cdn.com/ 'unsafe-inline' 'unsafe-eval'; connect-src * 'unsafe-inline'; img-src * data: blob: 'unsafe-inline'; frame-src * 'self' https://localhost:* https://localhost:8765 http://www.ninjawars.net http://ninjawars.net https://www.ninjawars.net; style-src 'self' https://kit.fontawesome.com https://fonts.gstatic.com https://fonts.googleapis.com data: blob: 'unsafe-inline'; font-src 'self' https://kit.fontawesome.com https://ka-f.fontawesome.com https://fonts.gstatic.com https://fonts.googleapis.com data: blob: 'unsafe-inline'; worker-src 'self' https://localhost:8765/ data: blob: 'unsafe-inline';"; # Check session via: php-fpm8.2 -i | grep session.gc fastcgi_param PHP_VALUE "session.cookie_domain= \n date.timezone=America/New_York \n default_charset=UTF-8 \n session.gc_maxlifetime=144000 \n display_errors=On \n"; - fastcgi_pass unix:/run/php/php8.2-fpm.sock; + fastcgi_pass unix:/run/php/php8.3-fpm.sock; fastcgi_param SCRIPT_FILENAME $document_root/front-controller.php; include fastcgi_params; } From 29b063166cf5c82ca301d874d0dbcbfd994ce4e9 Mon Sep 17 00:00:00 2001 From: Coco R Date: Mon, 16 Jun 2025 03:10:20 -0400 Subject: [PATCH 2/5] Add stealth_removing trait. --- deploy/lib/control/NpcController.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/deploy/lib/control/NpcController.php b/deploy/lib/control/NpcController.php index ebb73f051..dfe781407 100644 --- a/deploy/lib/control/NpcController.php +++ b/deploy/lib/control/NpcController.php @@ -319,11 +319,14 @@ public function attack(Container $p_dependencies) 'guard' => 'attackGuard', ]; + $npco = $victim? (new NpcFactory())->create($victim) : null; + $method = null; if ($player && $player->turns > 0 && !empty($victim)) { // Strip stealth when attacking special NPCs - if ($player->hasStatus(STEALTH) && in_array(strtolower($victim), self::$STEALTH_REMOVING_NPCS)) { + if ($player->hasStatus(STEALTH) && + (in_array(strtolower($victim), self::$STEALTH_REMOVING_NPCS) || ($npco && $npco->hasTrait('stealth_removing')))) { $player->subtractStatus(STEALTH); } From 449664387f51e4ee4e872e73532afdac6ef62af4 Mon Sep 17 00:00:00 2001 From: Coco R Date: Mon, 16 Jun 2025 03:10:58 -0400 Subject: [PATCH 3/5] Prototype samurai npc, template hooks for cm. --- deploy/npc-list.php | 26 +++++++++++++++++++++++--- deploy/templates/npc.abstract.tpl | 6 +++--- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/deploy/npc-list.php b/deploy/npc-list.php index aff34e160..8fdf852be 100644 --- a/deploy/npc-list.php +++ b/deploy/npc-list.php @@ -559,7 +559,7 @@ 'stamina' => 10, 'speed' => 30, 'ki' => 20, - 'short' => 'a horned demon', + 'short' => 'is a horned demon', 'img' => 'attacking_wandering_oni.jpg', 'race' => 'oni', 'inventory' => [ @@ -570,7 +570,8 @@ 'stealthy', 'slowing', 'energy_vampire', - 'horned' + 'horned', + 'stealth_removing' ], ], 'toad' => [ @@ -578,7 +579,7 @@ 'strength' => 1, 'stamina' => 3, 'speed' => 15, - 'short' => 'a slimy toad', + 'short' => 'is a slimy large beast', 'img' => 'matsuoto-hoji-toad.jpg', 'race' => 'animal', 'inventory' => [], @@ -586,5 +587,24 @@ 'amphibious', ], ], + 'samurai22' => [ + 'name' => 'Samurai', + 'short' => 'is an armored warrior', + 'race' => 'human', + 'strength' => 70, + 'stamina' => 30, + 'speed' => 12, + 'ki' => 1, + 'damage' => 20, + 'gold' => 100, + 'img' => 'samurai.png', + 'inventory' => [ + 'ginsengroot' => '.11', + ], + 'traits' => [ + 'partial_match_strength', + 'stealth_removing' + ], + ], ] ); diff --git a/deploy/templates/npc.abstract.tpl b/deploy/templates/npc.abstract.tpl index b2518b842..3a854dd3d 100644 --- a/deploy/templates/npc.abstract.tpl +++ b/deploy/templates/npc.abstract.tpl @@ -25,7 +25,7 @@ The {$race|escape} seems stronger than you! {/if} -

+

{if $attack_damage > 0} {if $npco->hasTrait('horned')}

The {$display_name|escape}'s horns gore you.

@@ -40,7 +40,7 @@ {/if}

-

+

You {if $ninja_damage > 0} {$ninja_damage_class} the {$display_name|escape} @@ -67,7 +67,7 @@

The {$display_name|escape} flees from you and escapes!

{else} {if $much_stronger} -

You are unable to end the {$display_name|escape}, so you escape instead!

+

You are unable to defeat the {$display_name|escape}, so you escape instead!

{else}

You fight to a standstill and neither wins.

{/if} From 93d8e6653042575d6beb460e5781facf7c6823c0 Mon Sep 17 00:00:00 2001 From: Coco R Date: Sun, 27 Jul 2025 00:06:34 -0400 Subject: [PATCH 4/5] Don't set sequence ids for login_attempts. --- deploy/sql/fixtures.sql | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/deploy/sql/fixtures.sql b/deploy/sql/fixtures.sql index 112903f2e..2ba8d0abc 100644 --- a/deploy/sql/fixtures.sql +++ b/deploy/sql/fixtures.sql @@ -398,14 +398,6 @@ COPY public.levelling_log (id, killpoints, levelling, killsdate, _player_id) FRO \. --- --- Data for Name: login_attempts; Type: TABLE DATA; Schema: public; Owner: developers --- - -COPY public.login_attempts (attempt_id, username, ua_string, ip, successful, additional_info, attempt_date) FROM stdin; -\. - - -- -- Data for Name: messages; Type: TABLE DATA; Schema: public; Owner: developers -- @@ -561,13 +553,6 @@ SELECT pg_catalog.setval('public.item_item_id_seq', 40, true); SELECT pg_catalog.setval('public.levelling_log_id_seq', 4471970, true); --- --- Name: login_attempts_attempt_id_seq; Type: SEQUENCE SET; Schema: public; Owner: developers --- - -SELECT pg_catalog.setval('public.login_attempts_attempt_id_seq', 1, false); - - -- -- Name: messages_message_id_seq; Type: SEQUENCE SET; Schema: public; Owner: developers -- From 21c987cb765c1f25831429d7009434bb72fa052e Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 31 Jul 2025 00:04:40 +0000 Subject: [PATCH 5/5] style: format code with PHP CS Fixer This commit fixes the style issues introduced in 93d8e66 according to the output from PHP CS Fixer. Details: https://github.com/BitLucid/ninjawars/pull/1890 --- deploy/lib/control/NpcController.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/deploy/lib/control/NpcController.php b/deploy/lib/control/NpcController.php index dfe781407..6f856b99f 100644 --- a/deploy/lib/control/NpcController.php +++ b/deploy/lib/control/NpcController.php @@ -319,13 +319,13 @@ public function attack(Container $p_dependencies) 'guard' => 'attackGuard', ]; - $npco = $victim? (new NpcFactory())->create($victim) : null; + $npco = $victim ? (new NpcFactory())->create($victim) : null; $method = null; if ($player && $player->turns > 0 && !empty($victim)) { // Strip stealth when attacking special NPCs - if ($player->hasStatus(STEALTH) && + if ($player->hasStatus(STEALTH) && (in_array(strtolower($victim), self::$STEALTH_REMOVING_NPCS) || ($npco && $npco->hasTrait('stealth_removing')))) { $player->subtractStatus(STEALTH); }