game.title = "Bloodfields"; global { command: "quit" { exit(); } } situation <> { setup { player.hpMax = 10; player.hpCur = player.hpMax; player.xp = 0; player.attack = 3; global.bJustTravelled = false; goto( <> ); } } function status() { display('You have ' + player.hpCur + ' of ' + player.hpMax + ' hp.'); } function look() { if( exists(global.enemy) )then { display('''You are standing in a field of wheat. You see a ''' + global.enemy['name'] + ''' in front of you.'''); } else { display('''You are standing in a field of wheat.'''); } // status(); } function mkEnemy() { global.enemy = { 'name': 'Snail', 'weapon': 'Tooth', 'attack': 3, 'hp': 5 }; } function rollAttack( attack ) { return( random( attack-attack/3, attack+attack/3 ) ); } function playerAttack() { damage = rollAttack( player.attack ); global.enemy['hp'] = global.enemy['hp'] - damage; display('You strike the ' + global.enemy['name'] + ' for ' + damage + ' damage.'); if global.enemy['hp'] <= 0 then { display('You killed the ' + global.enemy['name'] + '!'); delete( global.enemy ); } } function enemyAttack() { damage = rollAttack( global.enemy['attack'] ); player.hpCur -= damage; display("The " + global.enemy['name'] + ' strikes you for ' + damage + ' damage.'); if player.hpCur <= 0 then { display('The ' + global.enemy['name'] + ' killed you!'); exit(); } } situation <> { enter { delete( global.enemy ); display('You wander aimlessly through the seemingly endless field of wheat.'); select = random(1,3); if select == 1 then { mkEnemy(); display('''There's a ''' + global.enemy['name'] + ''' here!'''); } global.bJustTravelled = true; goto( <> ); } } situation <> { command: "attack" { if exists(global.enemy) then { playerAttack(); goto( <> ); } else { display('''There's nothing here to attack...'''); } } command: "look" { look(); } command: "walk" { if not exists(global.enemy) then { goto( <> ); } else { display("You can't walk around with an enemy in front of you! You can try to flee if you'd like..."); } } setup { look(); } enter { if not global.bJustTravelled then { if exists( global.enemy ) then { enemyAttack(); } status(); // look(); } else { } global.bJustTravelled = false; } }