from ._builtin import Page
from django.utils.safestring import mark_safe
class Investment(Page):
form_model = 'player'
form_fields = ['hours_spent_fishing', 'hours_spent_coconuts']
def error_message(self, values):
if values['hours_spent_fishing'] + values['hours_spent_coconuts'] > 12:
return 'You can only spend a maximum of 12 hours for fishing and gathering coconuts in total.'
class Trading(Page):
form_model = 'player'
form_fields = ['sent_fishes', 'sent_coconuts']
def error_message(self, values):
if values['sent_fishes'] > 0 and values['sent_coconuts'] > 0:
return mark_safe('You can either send fish to receive coconuts or send coconuts to receive fish ' +
'(or do nothing), but you are not allowed to choose more than one option.')
class Results(Page):
pass
page_sequence = [
Investment,
Trading,
Results
]