aiannacc / Goko-Salvager

Enhance your Dominion Online experience!
13 stars 9 forks source link

Add option to disable Adventure mode's brutal starting hands #226

Open amalloy opened 10 years ago

amalloy commented 10 years ago

DXV suggested that, until MF get their act together and do something sensible to Adventures, Salvager could force the starting decks to always be the standard 7 Copper, 3 Estate. I confirmed that CampaignClient.prototype.setHands is, as Donald said, the function responsible for rigging the starting hands. If I set it to something like

CampaignClient.prototype.setHands = function () {
  this.myHand = $.extend(true, [], ["copper", "copper", "copper", "copper", "copper", "copper", "copper", "estate", "estate", "estate"]);
  this.otherHand= $.extend(true, [], ["copper", "copper", "copper", "copper", "copper", "copper", "copper", "estate", "estate", "estate"]);
}

Then the "zapping" screen does reflect the normal starting decks, as expected. However, when I press Play, something goes wrong and the loading screen gets stuck very early on. I couldn't really figure out anything more than that, sadly.

serakfalcon commented 10 years ago

The issue is, there is a server side check to reduce your zaps. You can only change things within what is zap-possible due to this check (note that the code doesn't fail if it gives you negative zaps) So, for example, if you start with 5 copper/ 5 estates you cannot tell the server to start with 7 copper / 3 estates: it causes a server-side error since it's not possible to zap estates into copper. You could, however, alter myHand and otherHand using that code instead of using the zap interface if you wanted to, so long as it would be possible to do using zaps. We don't have access to the server-side code, however salvager already has a little check box that auto-zaps. It's not perfect (for some decks you'd rather not have silver) but it works.

On another note, there is no check for how many cards you can have, so as long as you and your opponent have at least the amount of victory cards/treasure cards that they start with, you can add more cards past the 10ts as long as you could get them via zaps. So, for example, I just successfully created an adventure game where the bot had 7 copper and 9 curses, and I had 7 silver and 4 estates.

aiannacc commented 10 years ago

No kidding? Can you just give yourself 8 Provinces then?

PS: I'm sure Alan posted this before our conversation with DVX in the Salvager thread.

serakfalcon commented 10 years ago

you can give yourself 8 duchies but not 8 provinces, since you can't get provinces via zaps. Yeah, I thought i'd update it based on what was shared in that thread and also added my own experimentation.

aiannacc commented 10 years ago

So... can you just automatically win with, say, 8 Duchies, 10 Curses, and 52 copper? 'cuz I want that feature.

serakfalcon commented 10 years ago

Apparently yes, with one caveat: you must have the first 10 in the right order. So, if you have 5 copper, 5 estates to start a game you must keep 5 treasure then 5 victory, then whatever you want.

serakfalcon commented 10 years ago

Also, it doesn't earn coins for some reason, which I guess doesn't matter that much....

serakfalcon commented 10 years ago
CampaignClient.prototype.setHands = function () {
      this.myHand = $.extend(true, [], ["silver", "silver", "silver", "silver", "silver", "silver","silver","duchy", "duchy", "duchy", "duchy","duchy","duchy","duchy","duchy","silver", "silver", "silver", "silver", "silver", "silver","silver","silver","silver","silver","silver", "silver", "silver", "silver", "silver", "silver","silver","silver","silver","silver","silver", "silver", "silver", "silver", "silver", "silver","silver","silver","silver","silver","silver","silver","silver"]);
      this.otherHand= $.extend(true, [], ["copper", "copper", "copper", "copper", "copper", "copper", "copper", "curse", "curse", "curse","curse","curse","curse","curse","curse","curse","curse"]);
}

This code seems to work for every single player game I've tested. In multiplayer games there are more duchies and curses so it doesn't drain the pile, but when you have the entire silver pile as your deck the game goes quickly.

serakfalcon commented 10 years ago

OK this code seems to work, I just beat the dark ages campaign in like, 5 minutes with it.

CampaignClient.prototype.setHands = function () {
    var gameData = this.campaignData[this.avatarWorld][this.avatarRegion];
    var i = 0;
    if(gameData) {
        this.myHand = $.extend(true,[],gameData.yourCards);
        for (i = 0;i<this.myHand.length;i++) {
            if (this.myHand[i] == "curse") {
                this.myHand[i] = "estate";
            }
        }
        console.log("yourCards:");
        console.log(gameData.yourCards);
    }
    this.otherHand=["copper", "copper", "copper", "copper", "copper", "copper", "copper", "curse", "curse", "curse","curse","curse","curse","curse","curse","curse","curse"];
}

CampaignClient.prototype.buildGameHands = function (campaign, game) {
    var gameData = this.campaignData[campaign][game];
    var hands = [];
    var i = 0;
    var numOpponents = gameData.numPlayers - 1;
    var defaultHand = ["copper", "copper", "copper", "copper", "copper", "copper", "copper","estate","estate","estate"];
    for (i = 0;i<10;i++) {
        defaultHand.push("curse");
    }
    this.myHand.push("duchy", "duchy", "duchy", "duchy","duchy","duchy","duchy","duchy");
    if (numOpponents > 1 ) {
        this.myHand.push("duchy","duchy","duchy","duchy");
    }
    for (var i =0; i<40; i++) {
        this.myHand.push("silver");
    }
    hands.push(this.myHand);
    hands.push(this.otherHand);
    for (i = 1; i < numOpponents; i++) {
        hands.push(defaultHand);
    }

    return hands;
}