Skip to content

Commit

Permalink
Speed up attack specs
Browse files Browse the repository at this point in the history
Does not need that long of a sleep
removed redundant spec
  • Loading branch information
grepsedawk committed Jul 29, 2023
1 parent 09f9eee commit a179c6a
Showing 1 changed file with 6 additions and 32 deletions.
38 changes: 6 additions & 32 deletions spec/integration/attack_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,7 @@ Spectator.describe Rosegold::Bot do
bot.chat "/kill @e[type=!minecraft:player]"
bot.chat "/fill -10 -60 -10 10 0 10 minecraft:air"
bot.chat "/fill -10 -61 -10 10 -61 10 minecraft:bedrock"
sleep 1
end
end
end

it "should be able to attack" do
client.join_game do |client|
Rosegold::Bot.new(client).try do |bot|
bot.chat "/tp @p -9 -60 9"
bot.chat "/time set 13000"
bot.chat "/kill @e[type=!minecraft:player]"
bot.chat "/clear"
sleep 1
bot.chat "/give #{bot.username} minecraft:diamond_sword"
bot.chat "/summon minecraft:zombie -9 -60 8 {NoAI:1}"
sleep 1
bot.inventory.pick! "diamond_sword"
bot.yaw = 180
bot.pitch = 0
20.times do
break if client.dimension.entities.select { |_, e| e.entity_type == 107 }.empty?
bot.chat "attack!"
bot.attack
bot.wait_ticks 20
end
# no zombies left
expect(client.dimension.entities.select { |_, e| e.entity_type == 107 }).to be_empty
bot.wait_tick
end
end
end
Expand All @@ -45,27 +19,27 @@ Spectator.describe Rosegold::Bot do
bot.chat "/time set 13000"
bot.chat "/kill @e[type=!minecraft:player]"
bot.chat "/clear"
bot.wait_ticks 5
bot.wait_for Rosegold::Clientbound::SetSlot

bot.chat "/give #{bot.username} minecraft:diamond_sword"
bot.wait_tick
bot.wait_for Rosegold::Clientbound::SetSlot
bot.chat "/fill -10 -60 8 0 -58 6 minecraft:dirt"
bot.wait_tick
bot.chat "/fill -9 -60 7 0 -58 7 minecraft:air"
bot.wait_tick
bot.chat "/fill -6 -60 7 -6 -60 7 minecraft:water"
bot.wait_tick
bot.chat "/fill -9 -59 8 -9 -59 8 minecraft:air"
bot.wait_tick
bot.chat "/summon minecraft:zombie -7 -60 7"
sleep 1

bot.inventory.pick! "diamond_sword"
bot.yaw = 180
bot.pitch = 0
20.times do
break if client.dimension.entities.select { |_, e| e.entity_type == 107 }.empty?
bot.chat "attack!"
bot.attack
bot.wait_ticks 20
bot.wait_ticks 13
end
# no zombies left
expect(client.dimension.entities.select { |_, e| e.entity_type == 107 }).to be_empty
Expand Down

0 comments on commit a179c6a

Please sign in to comment.