Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify rewards #147

Open
Mercerenies opened this issue Dec 25, 2023 · 2 comments
Open

Unify rewards #147

Mercerenies opened this issue Dec 25, 2023 · 2 comments
Labels
refactor Source code or internal bookkeeping that does not affect users

Comments

@Mercerenies
Copy link
Owner

Mercerenies commented Dec 25, 2023

We have a lot of different reward or effect classes right now, whose methods all boil down to some variant of

interface WhateverEffect {
  fun applyToPlayer(player: Player, context: SomeClass): Unit
}

Among these, we have

  • TriviaQuestionReward, which takes only a Player but also has a name: Component field.
  • CookieEffect, which has cancelsDefault() and its context is CookieEatenAction (stack, player, and death registry).
  • CakeEffect, which has cancelsDefault() and positivity, and its context is the location of the cake in the world.

These three should, at minimum, inherit from a common super-interface.

As a stretch goal, we also have BowserReward, which is different in that it rewards all players (with one player getting a special reward). It's not as similar to the others, but it's worth mentioning.

@Mercerenies
Copy link
Owner Author

The four classes, as they appear now (b68435d):

interface TriviaQuestionReward {
  val name: Component
  fun rewardPlayer(player: Player): Unit
}

interface CookieEffect {
  fun cancelsDefault(): Boolean
  fun onEat(action: CookieEatenAction)
}

interface BowserReward {
  fun getMainRewardText(): Component
  fun getSpecialRewardText(player: Player): Component
  fun giveMainReward(player: Player): Unit
  fun giveSpecialReward(player: Player): Unit
}

interface CakeEffect {
  fun cancelsDefault(): Boolean
  fun onEat(loc: Location, player: Player)
}

@Mercerenies Mercerenies added the refactor Source code or internal bookkeeping that does not affect users label Dec 25, 2023
@Mercerenies
Copy link
Owner Author

Doctor Dances also has a reward interface, and so does Prisoner's Dilemma

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
refactor Source code or internal bookkeeping that does not affect users
Projects
None yet
Development

No branches or pull requests

1 participant