def self.dispatch_poker(parsed, user:, network:, channel:, fetch: nil, probe: method(:default_probe), store: RabbotDb)
case parsed[:action]
when :start
forecast = fetch_forecast(parsed[:location], fetch: fetch, probe: probe)
return { error: "Forecast not found for #{parsed[:location]}" } unless forecast
result = BomPoker.start_round(
network: network,
channel: channel,
location: parsed[:location],
amount: parsed[:amount],
forecast: forecast,
store: store
)
return { error: result[:error] } if result[:error]
{ reply: result[:message] }
when :bet
result = BomPoker.place_bet(
network: network,
channel: channel,
user: user,
pick: parsed[:pick],
amount: parsed[:amount],
store: store
)
return { error: result[:error] } if result[:error]
{ reply: result[:message] }
when :settle
round = GameStore.load(plugin: BomPoker::PLUGIN, network: network, channel: channel, store: store)
return { error: "No Forecast Poker round to settle." } unless round
forecast = fetch_forecast(round["location"], fetch: fetch, probe: probe)
return { error: "Forecast not found for #{round['location']}" } unless forecast
result = BomPoker.settle_round(network: network, channel: channel, forecast: forecast, store: store)
return { error: result[:error] } if result[:error]
{ reply: result[:message] }
else
{ error: BomPoker.usage_message }
end
end