Add win condition

This commit is contained in:
Anton Vakhrushev 2019-10-06 13:58:36 +03:00
parent d200d59fff
commit e0b586ea6e
2 changed files with 8 additions and 1 deletions

View File

@ -11,7 +11,7 @@ world = Game::World.new(ts)
router = CLI::CommandRouter.new router = CLI::CommandRouter.new
router.add "st" do router.add "st" do
printf "Stat:\n Crystals: %d\n Tarraform: %d\n", printf "Stat:\n Crystals: %d\n Terraformation: %d\n",
world.resources[Game::ResourceType::Crystal], world.resources[Game::ResourceType::Crystal],
world.resources[Game::ResourceType::Terraformation] world.resources[Game::ResourceType::Terraformation]
end end
@ -89,6 +89,9 @@ loop do
current_time = Time.local.to_unix current_time = Time.local.to_unix
world.run current_time world.run current_time
printf "Now: %s\n\n", Time.unix(world.ts).to_local.to_s printf "Now: %s\n\n", Time.unix(world.ts).to_local.to_s
if world.win?
printf "YOU WIN!!!\n\n"
end
router.handle cmd router.handle cmd
printf "\n" printf "\n"
end end

View File

@ -32,4 +32,8 @@ class Game::World
end end
@ts = ts @ts = ts
end end
def win?
@resources[ResourceType::Terraformation] >= 100
end
end end