[Megameknet-cvs] MegaMekNET/src/server/campaign/tasks ConquerTask.java,1.24,1.25
Status: Inactive
Brought to you by:
mcwizard
From: Helge R. <mcw...@us...> - 2005-04-23 16:46:42
|
Update of /cvsroot/megameknet/MegaMekNET/src/server/campaign/tasks In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1954/src/server/campaign/tasks Modified Files: ConquerTask.java Log Message: -> S RFE [ 1188608 ] Planetary % -- before, please! McW 2005-04-23 Index: ConquerTask.java =================================================================== RCS file: /cvsroot/megameknet/MegaMekNET/src/server/campaign/tasks/ConquerTask.java,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** ConquerTask.java 6 Mar 2005 16:59:40 -0000 1.24 --- ConquerTask.java 23 Apr 2005 16:46:30 -0000 1.25 *************** *** 29,32 **** --- 29,36 ---- public class ConquerTask extends Task { private int winnerGain = 0; + private int attackerGain = UNDEFINDED; + private int defenderGain = UNDEFINDED; + + private static final int UNDEFINDED = -1; public ConquerTask(){ *************** *** 159,163 **** attackerforces = getAttacker().getArmy().getDescription(accurate); defenderforces = getDefender().getArmy().getDescription(accurate); ! return "#" + this.getID() + " <b>" + attackingP.getColoredName() + "(" + attackerfightingFor.getName() + ")</b>" + " attacking " + getTarget().getName() + " with " + attackerforces + ". Defender is: " + defendingP.getColoredName() + "(" + defenderFightingFor.getName() + ")" + " with " + defenderforces + " Percentage at stake: " + this.getPercentAtStake() + "%<br>"; } --- 163,167 ---- attackerforces = getAttacker().getArmy().getDescription(accurate); defenderforces = getDefender().getArmy().getDescription(accurate); ! return "#" + this.getID() + " <b>" + attackingP.getColoredName() + "(" + attackerfightingFor.getName() + ")</b>" + " attacking " + getTarget().getName() + " with " + attackerforces + ". Defender is: " + defendingP.getColoredName() + "(" + defenderFightingFor.getName() + ")" + " with " + defenderforces + " Percentage at stake: " + this.getPossibleAttackerGain() + "/" + getPossibleDefenderGain() + "%<br>"; } *************** *** 203,206 **** --- 207,224 ---- public void doGrantEXPandMoney() {} */ + + public int getPossibleAttackerGain(){ + if (attackerGain == UNDEFINDED ){ + attackerGain = getPercentAtStake(getActor(), getDefender()); + } + return attackerGain; + } + + public int getPossibleDefenderGain() { + if (defenderGain == UNDEFINDED){ + defenderGain = getPercentAtStake(getDefender(), getActor()); + } + return defenderGain; + } public void processTaskResult() { *************** *** 213,246 **** return; } - int gainpercentage = this.getPercentAtStake(); TaskPlayer winner = (TaskPlayer) this.getPlayersWhich("win").elementAt(0); TaskPlayer loser = (TaskPlayer) this.getPlayersWhich("loss").elementAt(0); ! /*if (!winner.isAttacker()) { ! //Winner lost enough to justify no planetary gain. ! if (((double) loser.getLostBV() / (double) loser.getInitialBV()) > 0.2) ! gainpercentage = 0; ! else ! this.sendToAll(loser.getPlayer().getName() + "'s forces were routed; in pursuing the soundly-defeated enemy " + winner.getPlayer().getName() + "'s forces advanced into enemy territory!", true); ! }*/ //Store the old owner SHouse oldowner = getTarget().getOwner(); - //Get a mod to the land gain based on frontline positions - int planetsInRange = CampaignMain.cm.getData().getPlanetsInRange(getTarget(),null, 35, Integer.parseInt(CampaignMain.cm.getConfig("ConquerFrontlineRange"))); - int planetsControlled = CampaignMain.cm.getData().getPlanetsInRange(getTarget(), winner.getPlayer().getMyHouse(),35, Integer.parseInt(CampaignMain.cm.getConfig("ConquerFrontlineRange"))); - if (planetsInRange != 0){ - double percentControlled = (double)planetsControlled / (double)planetsInRange; - if (percentControlled >= Double.parseDouble(CampaignMain.cm.getConfig("ConquerFrontlineBonus"))) - gainpercentage += 5; - else if (percentControlled <= Double.parseDouble(CampaignMain.cm.getConfig("ConquerFrontlineMalus"))) - gainpercentage -= 5; - } - //Defender gets half - if (!winner.isAttacker()) - gainpercentage = gainpercentage / 2; - if (gainpercentage <= 0) - gainpercentage = 1; - //Do the Land gain winnerGain = getTarget().doGainInfluence(winner.getPlayer().getHouseFightingFor(), loser.getPlayer().getHouseFightingFor(), gainpercentage); --- 231,247 ---- return; } TaskPlayer winner = (TaskPlayer) this.getPlayersWhich("win").elementAt(0); TaskPlayer loser = (TaskPlayer) this.getPlayersWhich("loss").elementAt(0); ! ! int gainpercentage; ! if (winner.isAttacker()){ ! gainpercentage = getPossibleAttackerGain(); ! } else { ! gainpercentage = getPossibleDefenderGain(); ! } //Store the old owner SHouse oldowner = getTarget().getOwner(); //Do the Land gain winnerGain = getTarget().doGainInfluence(winner.getPlayer().getHouseFightingFor(), loser.getPlayer().getHouseFightingFor(), gainpercentage); *************** *** 262,271 **** } ! public int getPercentAtStake() { TaskPlayer a = this.getActor(); TaskPlayer b = this.getDefender(); ! return getPercentAtStake(a.getPlayer(), b.getPlayer()); } ! public int getPercentAtStake(SPlayer attacker, SPlayer defender){ //Calulate the lowest ELO double lowestELO = attacker.getConqElo(); --- 263,290 ---- } ! public int getPercentAtStake(TaskPlayer winner, TaskPlayer loser) { TaskPlayer a = this.getActor(); TaskPlayer b = this.getDefender(); ! int gainpercentage = getPercentAtStakeBase(a.getPlayer(), b.getPlayer()); ! //Get a mod to the land gain based on frontline positions ! int planetsInRange = CampaignMain.cm.getData().getPlanetsInRange(getTarget(),null, 35, Integer.parseInt(CampaignMain.cm.getConfig("ConquerFrontlineRange"))); ! int planetsControlled = CampaignMain.cm.getData().getPlanetsInRange(getTarget(), winner.getPlayer().getMyHouse(),35, Integer.parseInt(CampaignMain.cm.getConfig("ConquerFrontlineRange"))); ! if (planetsInRange != 0){ ! double percentControlled = (double)planetsControlled / (double)planetsInRange; ! if (percentControlled >= Double.parseDouble(CampaignMain.cm.getConfig("ConquerFrontlineBonus"))) ! gainpercentage += 5; ! else if (percentControlled <= Double.parseDouble(CampaignMain.cm.getConfig("ConquerFrontlineMalus"))) ! gainpercentage -= 5; ! } ! //Defender gets half ! if (!winner.isAttacker()) ! gainpercentage = gainpercentage / 2; ! if (gainpercentage <= 0) ! gainpercentage = 1; ! ! return gainpercentage; ! } ! public int getPercentAtStakeBase(SPlayer attacker, SPlayer defender){ //Calulate the lowest ELO double lowestELO = attacker.getConqElo(); *************** *** 282,293 **** else gainpercentage = 1; ! /* ! if (a.getInitialBV() > 10000) ! gainpercentage++; ! if (a.getInitialBV() > 5000) ! gainpercentage++; ! if (a.getInitialBV() > 3000) ! gainpercentage++; ! */ if (eloDifference > 100 && lowestELO < 1750) gainpercentage--; --- 301,306 ---- else gainpercentage = 1; ! ! //Elo Mods if (eloDifference > 100 && lowestELO < 1750) gainpercentage--; *************** *** 297,361 **** gainpercentage--; - //Minimum of 1% if (gainpercentage <= 0) gainpercentage = 1; - - /* OLD WAY - if (lowestELO > 2000) - gainpercentage = 18; - else if (lowestELO > 1950) - gainpercentage = 16; - else if (lowestELO > 1900) - gainpercentage = 14; - else if (lowestELO > 1850) - gainpercentage = 12; - else if (lowestELO > 1800) - gainpercentage = 10; - else if (lowestELO > 1750) - gainpercentage = 8; - else if (lowestELO > 1700) - gainpercentage = 6; - else if (lowestELO > 1650) - gainpercentage = 4; - else if (lowestELO > 1600) - gainpercentage = 3; - else if (lowestELO > 1500) - gainpercentage = 2; - else - gainpercentage = 1; - - //Same ELO = BONUS! - if (ELOdifference < 50) - gainpercentage += 2; - - //Malus for unfair games - if (ELOdifference > 50) - gainpercentage--; - if (ELOdifference > 100) - gainpercentage--; - if (ELOdifference > 170) - gainpercentage--; - if (ELOdifference > 250) - gainpercentage--; - if (ELOdifference > 350) - gainpercentage--; - if (ELOdifference > 450) - gainpercentage--; - //Won't ever happen. But to be sure.. - if (ELOdifference > 550) - gainpercentage = 1; - - if (this.getActorArmy().getBV() < 3000) - gainpercentage = (int)((double)gainpercentage * (double)this.getActorArmy().getBV() / (double)3000); - - //Minimum of 1% - if (gainpercentage <= 0) - gainpercentage = 1; - */ return gainpercentage * 5; } public int getTaskMod(SPlayer attacker, SPlayer defender){ ! return getPercentAtStake(attacker, defender); } public int getTypeID(){ --- 310,322 ---- gainpercentage--; //Minimum of 1% if (gainpercentage <= 0) gainpercentage = 1; return gainpercentage * 5; } + + //Attacker determines the counter worthiness public int getTaskMod(SPlayer attacker, SPlayer defender){ ! return getPossibleAttackerGain(); } public int getTypeID(){ |