Major Voting Improvements!

Discussion in 'Empire Updates' started by Aikar, Feb 19, 2014.

  1. Not crazy, only curious.. xD
  2. First day after the new rewards were implemented and EMC moved up one place in ranks - seems to be working :)
    00void likes this.
  3. Sunlight is scattered from gasses and air (prisms) in the atmosphere. Blue light is most scattered, because it travels in short waves giving it more time to break up, whereas other colors of light have longer waves. This is why the sky appears blue.

    kthx
  4. Lol. To cut a long story short... do you have all the answers? Or are you limited only by what science can explain? :)
  5. I have not even ever had so much money :eek:
    72Volt likes this.
  6. Most of them.
  7. I think it's pretty cool of Aikar to share some of the inner workings of the servers and site with us.

    I think I can answer some of your questions. The code is javascript. Math.min() and Math.max() return the min or max of the two values passed to them. He also uses Math.floor() which returns the integer value of the passed parameter.

    The expression (60 * 60 * 30) actually is expressing 30 hours in terms of seconds. Based on the the way they are used, all of the variables including midnight and yesterday are probably in terms of seconds. He is probably also using some variation on Date().getTime() for timestamp which is the number of seconds since midnight Jan 1, 1970 so keeping these variables/constants all in terms of seconds saves him from converting them.

    From what I see from running through the code, he is giving us 100r per vote plus a 10r bonus per day up to 50 days after which you get 500r each day. It looks like voteMax is your current longest streak. Each time you beat your current streak he calls processRupeeBonus(), which I haven't seen listed, but I assume is where some of the large bonuses I've seen posted are coming from.

    When you beat your current streak he also calls processItemBonus(), which gives you the bonus items. Based on the conveniently named functions, I assume you get recurring bonuses of a Diamond every three days, an Emerald every 5, a Vault Voucher every 20, and a Stable Voucher every 50. You also get one time bonuses of a new armor piece at 20, 30, 40, 60, and a tyCertificate at 100.

    The last part is where your streak gets reset if you go over the 30 hours from your last vote. It subtracts off 2 days plus 2 days for every days you have missed, or 0 whichever is greater.

    Unless there is more, to reset it after 100 days, I think you would have to not vote for long enough to reset your streak at least to 19 in order to get the one time bonuses again(I come up with 39.5 days, hehe). I'm guessing that's the part he might be wanting to change since some people are already well over 200 days.
    NZScruffy, cddm95ace and weeh666 like this.
  8. Clever chap :cool:
  9. You only get one of the vault & stable vouchers.
    Pab10S likes this.
  10. I guess that's where the "should" in the function name comes into play. Without the code he could be rolling a twenty sided die for all I know.

    if (shouldGetEvery(20, "vaultVoucher")) {
    sendSystemMail(player, str, PromoItems.VAULT_VOUCHER);
    RainbowChin likes this.
  11. Pretty much spot on Pab,

    But the shouldGetEvery checks for the first and current iteration, so that it ensures you at least get one on your first vote since the update, and then you will resume getting more at the next interval.

    The code looks like this:

    Code:
            private void processRupeeBonus() {
                /*
                  DO NOT add any other logic after shouldGet* - do it BEFORE.
                  If one of the shouldGetItem returns true, it must deliver item.
                */
                if (shouldGetEvery(30, "rupee30")) {
                    voteRupees += 4000;
                }
                if (shouldGetEvery(15, "rupee15")) {
                    voteRupees += 1000;
                }
                if (shouldGetEvery(5, "rupee5")) {
                    voteRupees += 300;
                }
                if (shouldGetEvery(45, "rupee45")) {
                    voteRupees += 7500;
                }
                if (shouldGetAt(50, "rupee50")) {
                    voteRupees += 25000;
                }
                if (shouldGetEvery(100, "rupee100")) {
                    voteRupees += 40000;
                }
            }
            private boolean shouldGetEvery(int i, String key) {
                if (shouldGetAt(i, key)) {
                    return true;
                } else if ((voteBonus % i == 0) && !hasMetaKey(key + voteBonus)) {
                    setMetaKey(key + voteBonus);
                    return true;
                }
                return false;
            }
    
            private boolean shouldGetAt(int i, String key) {
                if (voteBonus >= i && !hasMetaKey(key + i)) {
                    setMetaKey(key + i);
                    return true;
                }
                return false;
            }
            private void setMetaKey(String key) {
                EmpireMetaKey metaKey = new EmpireMetaKey("votereward." + key, 0);
                EmpireUser.getUser(player).setMeta(metaKey, "1");
            }
    
            private boolean hasMetaKey(String key) {
                EmpireMetaKey metaKey = new EmpireMetaKey("votereward." + key, 0);
    
                return EmpireUser.getUser(player).getMeta(metaKey).getString() != null;
            }
    Empire Meta is a storage system to save data on players that is accessible Empire wide from every server :)
  12. So wait, we are meant to get more than one vault voucher?
    Me confuse -_-
  13. First vote no, but once you hit the next 20 mark you will get another.

    Essentially, I'm filling at least 1 item of the backlog... otherwise you would of been BOMBED with Diamonds/Emeralds.
  14. Ah, okay, its actually all been thought of then, good to hear :)
  15. If you were referring to me, thanks, but Aikar did all the work.

    I doubt if anyone would have complained about being bombed with Diamonds :)

    I'm out of break time, but without going through that last code I can see there is obviously a lot of incentive for voting. I especially like seeing the items included. I'll be sure to include the benefits of voting streaks when I tell other players about voting.
    00void likes this.
  16. I had a vote streak of 30+ a while ago, will get credit for that or do I have to do it again?
  17. You will need to get a streak of more than you had at the most at that time.
  18. Thx Nick,
  19. Thank you Aikar for the new bonuses. I thought maybe there was a glitch when I saw the bonus but now I see it was as it should be.
    Looking forward to seeing what 1 year voting streak might bring.
    607 likes this.
  20. So why not purple? It has an even shorter wavelength.