Small fixes
This commit is contained in:
parent
8f1ac6c74f
commit
d15aeaedc4
2
Makefile
2
Makefile
@ -24,5 +24,5 @@ run: format
|
||||
|
||||
.PHONY: spec
|
||||
spec: format
|
||||
./crystal spec --no-debug --warnings all --error-on-warnings --error-trace
|
||||
./crystal spec --warnings all --error-on-warnings --error-trace
|
||||
|
||||
|
@ -30,6 +30,9 @@ module Game
|
||||
if @building.mining
|
||||
world.push(MineCommand.new(@point))
|
||||
end
|
||||
if @building.restoration
|
||||
world.push(RestoreCommand.new(@point))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@ -51,10 +54,14 @@ module Game
|
||||
tile = world.map.get(@point).as(BuildingTile)
|
||||
building = tile.building
|
||||
mining = building.mining.as(Mining)
|
||||
if !world.resources.has(mining.input)
|
||||
return mining.ts
|
||||
end
|
||||
resource = mining.resource
|
||||
deposit_tile = nearest_deposit(world, resource.type)
|
||||
if deposit_tile
|
||||
@holded = Resource.new resource.type, deposit_tile.dep.dec(resource.amount)
|
||||
mined_amount = deposit_tile.dep.dec(resource.amount)
|
||||
@holded = resource.type.to_res mined_amount
|
||||
end
|
||||
mining.ts
|
||||
end
|
||||
|
@ -4,6 +4,10 @@ struct Game::Resource
|
||||
enum Type
|
||||
Crystals
|
||||
Terraformation
|
||||
|
||||
def to_res(amount : Capacity)
|
||||
Resource.new self, amount
|
||||
end
|
||||
end
|
||||
|
||||
def initialize(@type : Type, @amount : Capacity)
|
||||
|
@ -15,10 +15,11 @@ class Game::World
|
||||
getter queue
|
||||
getter score
|
||||
|
||||
def push(command : Command)
|
||||
def push(command : Command) : TimePoint
|
||||
dur = command.start(self)
|
||||
done_at = @ts + dur.to_i64
|
||||
@queue.push(done_at, command)
|
||||
done_at
|
||||
end
|
||||
|
||||
def run(ts : TimePoint)
|
||||
|
Loading…
Reference in New Issue
Block a user