yarcat / chemistry-lines

Chemistry Lines (game)
1 stars 0 forks source link

Replace GameLogic.getScore with listen/subscribe. #76

Open soulne4ny opened 11 years ago

soulne4ny commented 11 years ago

https://github.com/yarcat/chemistry-lines/commit/ce2161163cc303d1152fb714cd23e146e8bf1fec#commitcomment-2315909

soulne4ny commented 11 years ago

There are some problems in https://github.com/yarcat/chemistry-lines/commit/ec5530a15cdfd31c60ff359679e390ca0203f5ec:

soulne4ny commented 11 years ago

Please, review https://github.com/yarcat/chemistry-lines/commit/ec5530a15cdfd31c60ff359679e390ca0203f5ec.

yarcat commented 11 years ago
  1. Let's get rid of getScorer() by allowing to inject scorer into game logic (in this case creator will know the instance, and will be able to set/add listener(s))
  2. Base scorer can have implementation of update()

    public void update(CompoundReference ref) {
     String value = updateAndGetNewScore(ref);
     for (ScoreListener listener : mListeners) {
       listener.onScoreUpdate(value);
     }
    }

    or smth similar. In this case implementations will have to override updateAndGetNewScore, and listeners will be notified automagically.

  3. As we already discussed, this can be done through an init() call.
soulne4ny commented 11 years ago

We have following debts left in the issue:

soulne4ny commented 11 years ago

Please, review.