Monday, June 13, 2011

Player Equipment

So I spent the last night trying to find a really good way to do stat changes and make them universal from girls to assistants to player. This will make combat a huge less of a pain in the ass. Its just I'm not really happy with the code it seems to have to much redundancy. What would have been fine a year ago feels instead way to bloated. So if anyone has a better way I'm going to post the code...

Though using paste bin since it keeps formatting and doesn't create ugly code. Thanks in advance.


To the anonymous who posted the 4 megaupload files thank you. It saves me from trying to download 36 hotfile files... Still don't have it working but hopefully tonight some time.



  1. I'd love to help, but it doesn't make much sense out of context. It's odd that you have a ChangeStat class in the first place. Wouldn't that normally be part of your character class instead of passing a character to it? And addPoints seems to contain what amounts to setter code that just makes sure the stats don't get raised past max. I'd roll that up into one method of your character class. And you seem to be adding stats from Items. Unless that refers to potions and such, wouldn't you normally pass the character class some item references and calculate the final stats on the fly via a getter?

  2. The problem is we've got 3 different character classes: Player, Assistant, and Girl, all of which do very different things. What we really need is to roll all of the common functionality that Daisy's working on, right now, into a single, parent class that they can all inherit from.

    I've made this suggestion, before, but I went into further detail in the Code Review topic in the forum. I hope it made some kind of sense. (It really isn't that much tougher than what you're already doing. It just requires a new way of thinking.) If not, I'll try to clear up the confusing parts, or maybe someone can explain it a bit better.

  3. IChangeStat... does that I mean that this is an interface? Or are you using it to denote something else?

    The second test for "special" will never trigger since there is a test for "special" higher up the chain.

    For the clamping itself, just write this method:
    private int Clamp(int input, int change, int min, int max)
    if(input + change < min) {return min;}
    if(input + change > max) {return max;}
    return input + change;

    from there most of those statements become who.hp = Clamp(who.hp, changer, 0, who.HPMax);

  4. im not any good with codes and stuff and if this isnt the first time being suggested im sorry, but could you make some long term goals in the game like achieve a set lvl of wealth etc.?