-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbattle.occ
91 lines (84 loc) · 2.94 KB
/
battle.occ
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#INCLUDE "course.module"
PROC main (SHARED CHAN BYTE out!)
CHAN INT warrior.attacks.dragon :
CHAN INT dragon.attacks.warrior :
TIMER clock :
REC PROC warrior (CHAN INT attack, be.attacked, VAL INT hp, sp)
INT damage, now :
INITIAL INT max.warrior.sp IS 10 :
SEQ -- I'd really like to remove this
CLAIM out! -- this
out.string("--", 0, out!) -- and this lines
ALT
TRUE & SKIP
SEQ
clock ? now -- delay to avoid polluting output
clock ? AFTER now PLUS 10000
CLAIM out!
out.string(".", 0, out!)
warrior(attack, be.attacked, hp, sp)
((hp > 0) AND (sp < max.warrior.sp)) & SKIP
SEQ
CLAIM out!
SEQ
out.string("Warrior recovers 1 sp.*n", 0, out!)
warrior(attack, be.attacked, hp, sp + 1)
((hp > 0) AND (sp >= 3)) & SKIP
SEQ
attack ! 5
warrior(attack, be.attacked, hp, sp - 1)
hp > 0 & be.attacked ? damage
SEQ
CLAIM out!
SEQ
out.string("Warrior receives ", 0, out!)
out.int(damage, 0, out!)
out.string(" damage and now has ", 0, out!)
out.int(hp - damage, 0, out!)
out.string(" hp.*n", 0, out!)
warrior(attack, be.attacked, hp - damage, sp)
:
REC PROC dragon (CHAN INT attack, be.attacked, VAL INT hp, sp)
INT damage, now :
INITIAL INT max.dragon.sp IS 10 :
SEQ -- I'd really like to remove this
CLAIM out! -- this
out.string("--", 0, out!) -- and this lines
ALT
TRUE & SKIP
SEQ
clock ? now -- delay to avoid polluting output
clock ? AFTER now PLUS 10000
CLAIM out!
out.string(".", 0, out!)
dragon(attack, be.attacked, hp, sp)
((hp > 0) AND (sp < max.dragon.sp)) & SKIP
SEQ
CLAIM out!
SEQ
out.string("Dragon recovers 1 sp.*n", 0, out!)
dragon(attack, be.attacked, hp, sp + 1)
((hp > 0) AND (sp >= 3)) & SKIP
SEQ
attack ! 5
dragon(attack, be.attacked, hp, sp - 1)
hp > 0 & be.attacked ? damage
SEQ
CLAIM out!
SEQ
out.string("Dragon receives ", 0, out!)
out.int(damage, 0, out!)
out.string(" damage and now has ", 0, out!)
out.int(hp - damage, 0, out!)
out.string(" hp.*n", 0, out!)
dragon(attack, be.attacked, hp - damage, sp)
:
SEQ
VAL INT warrior.hp IS 10 :
VAL INT warrior.sp IS 3 :
VAL INT dragon.hp IS 10 :
VAL INT dragon.sp IS 3 :
PAR
warrior (warrior.attacks.dragon, dragon.attacks.warrior, warrior.hp, warrior.sp)
dragon (dragon.attacks.warrior, warrior.attacks.dragon, dragon.hp, dragon.sp)
: