summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--bloodfields.stage27
-rw-r--r--src/parser.y4
-rw-r--r--test.stage8
3 files changed, 15 insertions, 24 deletions
diff --git a/bloodfields.stage b/bloodfields.stage
index 91bee08..58a24a2 100644
--- a/bloodfields.stage
+++ b/bloodfields.stage
@@ -78,21 +78,15 @@ function status()
78 78
79function look() 79function look()
80{ 80{
81 display('''You are standing in a field of wheat.''');
81 if exists(global.enemy) then 82 if exists(global.enemy) then
82 { 83 {
83 display('''You are standing in a field of wheat. You see a ''' + 84 display('You see a ' + global.enemy['name'] + ' in front of you.');
84 global.enemy['name'] + ''' in front of you.''');
85 } 85 }
86 else if exists( global.treasure ) then 86 else if exists( global.treasure ) then
87 { 87 {
88 display('''You are standing in a field of wheat. You find a ''' + 88 display('You find a ' + global.treasure['name'] + ' lying here!');
89 global.treasure['name'] + ''' lying here!''');
90 } 89 }
91 else
92 {
93 display('''You are standing in a field of wheat.''');
94 }
95// status();
96} 90}
97 91
98function mkEnemy() 92function mkEnemy()
@@ -107,9 +101,8 @@ function mkEnemy()
107 } 101 }
108 global.enemy['name'] = global.enemyMods[mod]['name'] + ' ' + 102 global.enemy['name'] = global.enemyMods[mod]['name'] + ' ' +
109 global.enemy['name']; 103 global.enemy['name'];
110 global.enemy['attack'] = global.enemy['attack'] + 104 global.enemy['attack'] += global.enemyMods[mod]['attack'];
111 global.enemyMods[mod]['attack']; 105 global.enemy['hp'] += global.enemyMods[mod]['hp'];
112 global.enemy['hp'] = global.enemy['hp'] + global.enemyMods[mod]['hp'];
113 global.enemy['level'] = mod; 106 global.enemy['level'] = mod;
114} 107}
115 108
@@ -137,7 +130,7 @@ function playerAttack()
137 display('You killed the ' + global.enemy['name'] + '! You gained ' + 130 display('You killed the ' + global.enemy['name'] + '! You gained ' +
138 xp + ' experience points.'); 131 xp + ' experience points.');
139 player.xp += xp; 132 player.xp += xp;
140 if player.xp >= 100 then 133 while player.xp >= 100 do
141 { 134 {
142 player.xp -= 100; 135 player.xp -= 100;
143 player.level += 1; 136 player.level += 1;
@@ -176,16 +169,12 @@ function enemyAttack()
176 169
177situation <<travel>> 170situation <<travel>>
178{ 171{
179 command: "hi"
180 {
181 display("Yup, you're in travel.");
182 }
183
184 enter 172 enter
185 { 173 {
186 delete( global.enemy ); 174 delete( global.enemy );
175 delete( global.treasure );
187 176
188 display('You wander aimlessly through the seemingly endless field of wheat.'); 177 display('You wander aimlessly through the endless field of wheat.');
189 178
190 select = random(1,6); 179 select = random(1,6);
191 if select <= 4 then // 66% of the time, enemy! 180 if select <= 4 then // 66% of the time, enemy!
diff --git a/src/parser.y b/src/parser.y
index 2e9eead..2aff29c 100644
--- a/src/parser.y
+++ b/src/parser.y
@@ -245,6 +245,10 @@ expr: literal
245 | expr tokGtEq expr { bld.addNode( AstNode::tCompGtEq ); } 245 | expr tokGtEq expr { bld.addNode( AstNode::tCompGtEq ); }
246 | '(' expr ')' 246 | '(' expr ')'
247 | expr '[' expr ']' { bld.addNode( AstNode::tIndex ); } 247 | expr '[' expr ']' { bld.addNode( AstNode::tIndex ); }
248 | expr '[' expr ']' tokPlusAssign { bld.addNode( AstNode::tIndex ); } expr { bld.addNode( AstNode::tPlusStore ); }
249 | expr '[' expr ']' tokMinusAssign { bld.addNode( AstNode::tIndex ); } expr { bld.addNode( AstNode::tMinusStore ); }
250 | expr '[' expr ']' tokTimesAssign { bld.addNode( AstNode::tIndex ); } expr { bld.addNode( AstNode::tMultiplyStore ); }
251 | expr '[' expr ']' tokDivideAssign { bld.addNode( AstNode::tIndex ); } expr { bld.addNode( AstNode::tDivideStore ); }
248 | expr '[' expr ']' '=' expr { bld.addNode( AstNode::tInsert ); } 252 | expr '[' expr ']' '=' expr { bld.addNode( AstNode::tInsert ); }
249 | '[' ']' { bld.addLiteral( Variable( Variable::tList ) ); } 253 | '[' ']' { bld.addLiteral( Variable( Variable::tList ) ); }
250 | '[' { bld.addLiteral( Variable( Variable::tList ) ); } listValues ']' 254 | '[' { bld.addLiteral( Variable( Variable::tList ) ); } listValues ']'
diff --git a/test.stage b/test.stage
index 4ffec79..42529af 100644
--- a/test.stage
+++ b/test.stage
@@ -17,11 +17,9 @@ situation <<start>>
17{ 17{
18 setup 18 setup
19 { 19 {
20 for each i in [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] do 20 global.stuff = {'count': 1};
21 { 21 global.stuff['count'] += 5;
22 display( random(0.25, 0.5)*10 ); 22 display( global.stuff['count'] );
23 }
24 display( 0.25 * 10.0 );
25 exit(); 23 exit();
26 } 24 }
27 25