From a181026effe4b7b33a83e836749905309691ae88 Mon Sep 17 00:00:00 2001 From: Tristan Le Guern Date: Thu, 20 May 2021 22:36:03 +0200 Subject: [PATCH] The evil Wumpus moves when an arrow is lost --- README.md | 9 +++--- molecule/default/converge.yml | 1 + molecule/default/move-wumpus.yml | 48 ++++++++++++++++++++++++++++++++ move-wumpus.yml | 27 ++++++++++++++++++ the-end.yml | 16 ++++++++++- wumpus-tasks.yml | 5 +++- 6 files changed, 100 insertions(+), 6 deletions(-) create mode 100644 molecule/default/move-wumpus.yml create mode 100644 move-wumpus.yml diff --git a/README.md b/README.md index 83bb61f..2589553 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/molecule/default/converge.yml b/molecule/default/converge.yml index 6db57f8..fe23e6f 100644 --- a/molecule/default/converge.yml +++ b/molecule/default/converge.yml @@ -15,3 +15,4 @@ - import_playbook: bogus-shoot.yml - import_playbook: deaths.yml - import_playbook: starting-position.yml +- import_playbook: move-wumpus.yml diff --git a/molecule/default/move-wumpus.yml b/molecule/default/move-wumpus.yml new file mode 100644 index 0000000..6fc32be --- /dev/null +++ b/molecule/default/move-wumpus.yml @@ -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'] diff --git a/move-wumpus.yml b/move-wumpus.yml new file mode 100644 index 0000000..b525256 --- /dev/null +++ b/move-wumpus.yml @@ -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'] diff --git a/the-end.yml b/the-end.yml index 89d5971..db1c558 100644 --- a/the-end.yml +++ b/the-end.yml @@ -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*! @@ -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. diff --git a/wumpus-tasks.yml b/wumpus-tasks.yml index 84f1d3b..fc9f21f 100644 --- a/wumpus-tasks.yml +++ b/wumpus-tasks.yml @@ -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