Repository navigation
fix(status): stop generic decay from racing the web struggle branch #166
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| (ns xsofy.test.status-test | ||
| (:require [test :refer [deftest is testing]] | ||
| [xsofy.terrain :as terrain] | ||
| [xsofy.fire :as fire] | ||
| [xsofy.status :as status] | ||
| [xsofy.world :as world])) | ||
|
|
||
| ;; Regression tests for #161: webs no longer trampled. | ||
| ;; | ||
| ;; :webbed ttl is decremented by the movement struggle branches, which | ||
| ;; trample the web on the last struggle. The generic status tick also | ||
| ;; decremented it, so the ttl drained twice per turn and expired inside | ||
| ;; the tick — which removes the status silently, without trampling. The | ||
| ;; struggle branch then never saw ttl <= 1 and the web survived every | ||
| ;; escape. :webbed is now :no-decay: the struggle branches own its ttl. | ||
|
|
||
| (deftest generic-tick-leaves-webbed-alone | ||
| (testing ":no-decay statuses keep their ttl through the generic tick" | ||
| (let [w {:entities {:e {:id :e :pos [1 1]}}} | ||
| w (status/apply-status w :e :webbed 2) | ||
| w (status/apply-status w :e :confused 2) | ||
|
mparrett marked this conversation as resolved.
|
||
| w (status/tick-entity-statuses w :e)] | ||
| ;; still webbed, ttl untouched | ||
| (is (= 2 (get-in w [:entities :e :statuses :webbed :ttl]))) | ||
| ;; the normal decay path still works | ||
| (is (= 1 (get-in w [:entities :e :statuses :confused :ttl]))) | ||
| (let [w (status/tick-entity-statuses w :e)] | ||
| (is (status/has-status? w :e :webbed)) | ||
| (is (not (status/has-status? w :e :confused))))))) | ||
|
|
||
| (deftest webbed-player-break-free-tramples-web | ||
| (testing "player struggling free of a web leaves ash, not an intact web" | ||
| (let [w (world/make-world 30 20 1) | ||
| [px py] (get-in w [:entities :player :pos]) | ||
| _ (terrain/tset! (:terrain w) (:width w) px py fire/web-tile) | ||
| w (status/apply-status w :player :webbed 2) | ||
| w (world/player-move w 1 0) ;; struggle: ttl 2 -> 1 | ||
| w (world/player-move w 1 0)] ;; final struggle: break free + trample | ||
| (is (not (status/has-status? w :player :webbed))) | ||
| (is (= fire/ash-tile (terrain/tget (:terrain w) (:width w) px py)))))) | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.