diff options
author | David Gay <david@davidgay.org> | 2021-07-14 17:08:56 -0400 |
---|---|---|
committer | David Gay <david@davidgay.org> | 2021-07-14 17:08:56 -0400 |
commit | f02a38cfc1a38a0c1fdc4d00cc10f47bb987b7d0 (patch) | |
tree | 2c4c02063d2585d720eee4bde06b35106dc0c097 /app/lib | |
parent | 847ee6ee3d41efe04a46b263e56027db0cf3ee64 (diff) |
Only allow one living monster_spawn per location
Diffstat (limited to 'app/lib')
-rw-r--r-- | app/lib/activity_processor.rb | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/app/lib/activity_processor.rb b/app/lib/activity_processor.rb index 4ba3609..d3bf5cb 100644 --- a/app/lib/activity_processor.rb +++ b/app/lib/activity_processor.rb @@ -118,8 +118,12 @@ class ActivityProcessor when "create_monster_spawn" next if rand > (result[:chance] || 1) monster = Monster.find_by_gid(result[:gid]) - MonsterSpawn.create(monster: monster, location: @character.location) - @results.push({ type: type, monster: monster }) + monster_spawn = MonsterSpawn.new(monster: monster, location: @character.location) + if monster_spawn.save + @results.push({ type: type, monster: monster }) + else + @results.push({ type: "message", body: "A leviathan did not appear since there is already a leviathan at #{@character.location.name}." }) + end else raise "Invalid result type (#{type})" # TODO: Improve this. end |