summaryrefslogtreecommitdiff
path: root/app/lib/activity_processor.rb
diff options
context:
space:
mode:
authorDavid Gay <david@davidgay.org>2021-07-14 17:27:26 -0400
committerDavid Gay <david@davidgay.org>2021-07-14 17:27:26 -0400
commitb8aa0a69cbdc8b145592ac142c397e0520021fdd (patch)
tree3dc60a2d516fd04729cddb301e3b1ec3639e4603 /app/lib/activity_processor.rb
parentf02a38cfc1a38a0c1fdc4d00cc10f47bb987b7d0 (diff)
Only allow a character to hunt up to two different leviathans in a 24 hour period
Diffstat (limited to 'app/lib/activity_processor.rb')
-rw-r--r--app/lib/activity_processor.rb13
1 files changed, 10 insertions, 3 deletions
diff --git a/app/lib/activity_processor.rb b/app/lib/activity_processor.rb
index d3bf5cb..d14282e 100644
--- a/app/lib/activity_processor.rb
+++ b/app/lib/activity_processor.rb
@@ -40,14 +40,17 @@ class ActivityProcessor
puts "Result: #{result}"
handle_xp_result(result)
when "monster_spawn"
+ monster_spawn = MonsterSpawn.where(location: Location.find_by_gid(result[:location])).select(&:alive?).first
+ raise MonsterSpawnError unless monster_spawn
+
raise TooManyWoundsError unless @character.can_fight?
+ unless @character.monster_spawns_attacked_in_past_24_hours.count < 2 || @character.monster_spawns_attacked_in_past_24_hours.include?(monster_spawn)
+ raise TooManyMonsterSpawnCombatsError
+ end
next if rand > (result[:chance] || 1)
@results.push({ type: "br" })
- monster_spawn = MonsterSpawn.where(location: Location.find_by_gid(result[:location])).select(&:alive?).first
- raise MonsterSpawnError unless monster_spawn
-
@results.push({ type: type, monster_spawn: monster_spawn })
resolve_combat_with(monster_spawn)
break
@@ -186,6 +189,10 @@ class ActivityProcessor
@character.stop_activity
@results.replace([{ type: "error",
message: "There are no living leviathans here." }])
+ rescue TooManyMonsterSpawnCombatsError
+ @character.stop_activity
+ @results.replace([{ type: "error",
+ message: "You're too worn out to hunt any more leviathans right now. You can only hunt two different leviathans in a 24 hour period." }])
end
private