Skip to content

Commit

Permalink
The evil Wumpus moves when an arrow is lost
Browse files Browse the repository at this point in the history
  • Loading branch information
tleguern committed May 20, 2021
1 parent 1e59902 commit a181026
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 6 deletions.
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,17 @@ Here is a list of intended features for first release:
- [X] Smelling nearby wumpii ;
- [X] Shoot arrows ;
- [X] Hard stop for arrows at 4 rooms ;
- [ ] Random chances that the arrow fail after 3 rooms ;
- [ ] The Wumpus awakens and moves on shot failure ;
- [X] The Wumpus awakens and moves on shot failure ;

Features not fit for the first release:

- [ ] Random chances that the arrow fail after 3 rooms ;
- [ ] Difficulty selection ;
- [ ] Generation of different shapes of cave as in `Hunt the Wumpus II`;
- [ ] Generation of different shapes of cave as in `Hunt the Wumpus II` ;
- [ ] Add _tumaeros_: anaerobic termite, arrows eaters ;
- [ ] The player can survive walking on a pit (1/6) ;
- [ ] The Wumpus can awaken and move on bumping walls (1/6);
- [ ] The Wumpus can awaken and move on bumping walls (1/6) ;
- [ ] Bats can drop player on other bats.

## Caveats

Expand Down
1 change: 1 addition & 0 deletions molecule/default/converge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
- import_playbook: bogus-shoot.yml
- import_playbook: deaths.yml
- import_playbook: starting-position.yml
- import_playbook: move-wumpus.yml
48 changes: 48 additions & 0 deletions molecule/default/move-wumpus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
- name: Wumpus move on shoot fail
hosts: all
become: no
gather_facts: no
vars:
death: no
hit: no
testing: yes
failedhit: no
cave:
"1":
connect: ["2"]
wumpus: false
pit: false
"2":
connect: ["1", "3"]
wumpus: false
pit: false
"3":
connect: ["2"]
wumpus: true
pit: false
tasks:
- name: Teleport to room 2.
set_fact:
position: "2"

- name: Create one arrow in the quiver.
set_fact:
arrows: "1"

- name: Shoot from room 2 to 1.
include_tasks: ../../shoot.yml
vars:
rooms: "1"

- name: Wumpus moves to a random room which happens to be 2.
include_tasks: ../../move-wumpus.yml

- name: Should die by being walked on by the evil Wumpus.
assert:
that:
- arrow == "1"
- arrows == "0"
- death
- not hit
- failedhit
- cave[position]['wumpus']
27 changes: 27 additions & 0 deletions move-wumpus.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
- name: Find where is the Wumpus.
set_fact:
wumpuspos: "{{ item.key }}"
with_dict: "{{ cave }}"
loop_control:
label: 'redacted'
when: item.value.wumpus

- name: Pick a room for the Wumpus to move to.
set_fact:
wumpusmove: "{{ (cave|json_query(query)|list|first).connect | random }}"
vars:
query: '* | [?wumpus]'

- name: Update the cave.
set_fact:
cave: "{{ cave | combine({ wumpuspos|string: {'wumpus': false}}, recursive=True) }}"

- name: Update the cave.
set_fact:
cave: "{{ cave | combine({ wumpusmove|string: {'wumpus': true}}, recursive=True) }}"

- name: Did the Wumpus moved onto you?
set_fact:
death: yes
when: cave[position]['wumpus']
16 changes: 15 additions & 1 deletion the-end.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,20 @@
- death
- cave[position]['pit']

- name: The End | Game over by evil Wumpus.
- name: The End | Game over by evil Wumpus walking to you.
set_fact:
endmsg: |
Oh dear. All the commotion has managed to awaken the evil Wumpus, who
has chosen to walk into this very room! Your eyes open wide as they behold
the great sucker-footed bulk that is the Wumpus; the mouth of the Wumpus
also opens wide as the evil beast beholds dinner.
*ROAR* *chomp* *snurfle* *chomp*!
when:
- death
- failedhit
- cave[position]['wumpus']

- name: The End | Game over by walking to the evil Wumpus.
set_fact:
endmsg: |
*ROAR* *chomp* *snurfle* *chomp*!
Expand All @@ -23,6 +36,7 @@
pass out from the stench!
when:
- death
- not failedhit
- cave[position]['wumpus']

- name: The End | Game over by lack of arrows.
Expand Down
5 changes: 4 additions & 1 deletion wumpus-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,12 @@
- include_tasks: "{{ command }}.yml"
when: "command in commands"

- include_tasks: "help.yml"
- include_tasks: help.yml
when: "command not in commands"

- include_tasks: move-wumpus.yml
when: failedhit

- include_tasks: the-end.yml
when: death or hit or arrows == 0

Expand Down

0 comments on commit a181026

Please sign in to comment.