-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patharrow.yml
73 lines (60 loc) · 1.8 KB
/
arrow.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
---
- name: Arrow | Get nextroom.
set_fact:
nextroom: "{{ rooms[roomcnt|int] }}"
- name: Arrow | Increase counter.
set_fact:
roomcnt: "{{ roomcnt|int + 1 }}"
- name: Arrow | Is the arrow not too far?
set_fact:
toofar: yes
when: "roomcnt|int >= 5"
- name: Arrow | Greedy shot.
debug:
msg: |
The arrow wavers in its flight and can go no further than room {{ arrow }}
when: toofar
- block:
- name: Arrow | Can the arrow fly to the next room?
set_fact:
canitfly: "{{ (nextroom in cave[arrow]['connect']) | ternary('yes', 'no') }}"
- name: Arrow | Yes, define arrow position.
set_fact:
arrow: "{{ nextroom }}"
when: canitfly|bool
- name: Arrow | No.
when: not canitfly|bool
block:
- name: No | Pick a random room to fly to.
set_fact:
randomroom: "{{ cave[arrow]['connect']| random }}"
- name: No | Thunk
debug:
msg: "*thunk* The arrow can't find a way from {{ position }} to {{ nextroom }} and flies randomly into room {{ randomroom }}!"
- name: No | Define arrow position.
set_fact:
arrow: "{{ randomroom }}"
- name: Arrow | Does the arrow hit the Wumpus?
set_fact:
hit: true
when: cave[arrow]['wumpus']
- name: Arrow | Does the arrow hit the Player?
set_fact:
death: yes
when: arrow == position
when: not toofar
- block:
- name: Arrow | Is it the last room?
set_fact:
failedhit: yes
when: "(rooms|length) == (roomcnt|int)"
- name: Arrow | Yes it is.
debug:
msg: "The arrow hit nothing."
when: failedhit
when:
- not hit
- not death
- not toofar
- include_tasks: arrow.yml
when: not toofar and not failedhit and not death and not hit