Ticket #3702: lockedTeams2.patch
File lockedTeams2.patch, 4.6 KB (added by , 8 years ago) |
---|
-
gui/session/menu.js
295 295 Engine.GetGUIObjectByName("diplomacyPlayerCiv["+(i-1)+"]").caption = g_CivData[g_Players[i].civ].Name; 296 296 Engine.GetGUIObjectByName("diplomacyPlayerTeam["+(i-1)+"]").caption = (g_Players[i].team < 0) ? translateWithContext("team", "None") : g_Players[i].team+1; 297 297 Engine.GetGUIObjectByName("diplomacyPlayerTheirs["+(i-1)+"]").caption = (i == g_ViewedPlayer) ? "" : (g_Players[i].isAlly[g_ViewedPlayer] ? translate("Ally") : (g_Players[i].isNeutral[g_ViewedPlayer] ? translate("Neutral") : translate("Enemy"))); 298 299 // Don't display the options for ourself , or if we or the other player aren't active anymore300 if (i == g_ViewedPlayer|| g_Players[i].state != "active")301 {302 // Hide the unused/unselectable options303 for (let a of ["TributeFood", "TributeWood", "TributeStone", "TributeMetal", "Ally", "Neutral", "Enemy"])304 Engine.GetGUIObjectByName("diplomacyPlayer"+a+"["+(i-1)+"]").hidden = true;305 Engine.GetGUIObjectByName("diplomacyAttackRequest["+(i-1)+"]").hidden = true;298 299 // Don't display the options for ourself 300 if (i == g_ViewedPlayer || g_Players[g_ViewedPlayer].state != "active" || g_Players[i].state != "active") 301 { 302 // Hide the unused/unselectable options 303 for (let action of ["TributeFood", "TributeWood", "TributeStone", "TributeMetal", "Ally", "Neutral", "Enemy"]) 304 Engine.GetGUIObjectByName("diplomacyPlayer"+action+"["+(i-1)+"]").hidden = true; 305 Engine.GetGUIObjectByName("diplomacyAttackRequest["+(i-1)+"]").hidden = true; 306 306 continue; 307 }308 307 } 308 309 309 // Tribute 310 310 for (let resource of RESOURCES) 311 311 { … … 353 353 button.onpress = (function(i) { return function() { 354 354 Engine.PostNetworkCommand({ "type": "attack-request", "source": g_ViewedPlayer, "target": i }); 355 355 }; })(i); 356 357 //Don't display tribute options but do display attack options if teams locked and not on our team 358 if (g_Players[g_ViewedPlayer].teamsLocked && (g_Players[g_ViewedPlayer].team != -1 && g_Players[i].team != -1 && g_Players[i].team != g_Players[g_ViewedPlayer].team)) 359 { 360 // Hide the unused/unselectable options 361 for (let action of ["TributeFood", "TributeWood", "TributeStone", "TributeMetal", "Ally", "Neutral", "Enemy"]) 362 Engine.GetGUIObjectByName("diplomacyPlayer"+action+"["+(i-1)+"]").hidden = true; 363 } 356 364 357 // Skip our own teams on teams locked358 if (g_Players[g_ViewedPlayer].teamsLocked && g_Players[g_ViewedPlayer].team != -1 && g_Players[ g_ViewedPlayer].team == g_Players[i].team)365 // Skip our own teams and other teams on teams locked 366 if (g_Players[g_ViewedPlayer].teamsLocked && g_Players[g_ViewedPlayer].team != -1 && g_Players[i].team != -1) 359 367 continue; 360 368 361 369 // Diplomacy settings -
simulation/components/Player.js
403 403 404 404 Player.prototype.SetDiplomacy = function(dipl) 405 405 { 406 // Should we check for teamsLocked here?407 406 this.diplomacy = dipl; 408 407 Engine.BroadcastMessage(MT_DiplomacyChanged, {"player": this.playerID}); 409 408 }; … … 424 423 // You can have alliances with other players, 425 424 if (this.teamsLocked) 426 425 { 427 // but can't stab your team members in the back428 if ( this.team == -1 || this.team != cmpPlayer.GetTeam())426 // Break alliance or declare war 427 if (Math.min(this.diplomacy[idx],cmpPlayer.diplomacy[this.playerID]) > value) 429 428 { 430 // Break alliance or declare war431 if ( Math.min(this.diplomacy[idx],cmpPlayer.diplomacy[this.playerID]) > value)429 // Can't stab your team members in the back 430 if (this.team == -1 || cmpPlayer.GetTeam() == -1 || this.team != cmpPlayer.GetTeam()) 432 431 { 433 432 this.diplomacy[idx] = value; 434 433 cmpPlayer.SetDiplomacyIndex(this.playerID, value); 435 434 } 436 else 437 { 435 } 436 else 437 { 438 //Allow upgrading relations to neutral only 439 if (this.team == -1 || cmpPlayer.GetTeam() == -1 || (this.team != cmpPlayer.GetTeam() && value == 0)) 438 440 this.diplomacy[idx] = value; 439 }440 Engine.BroadcastMessage(MT_DiplomacyChanged, {"player": this.playerID});441 441 } 442 Engine.BroadcastMessage(MT_DiplomacyChanged, {"player": this.playerID}); 442 443 } 443 444 else 444 445 { … … 714 715 715 716 if (this.state != "active" || cmpPlayer.state != "active") 716 717 return; 717 718 719 if (this.teamsLocked && this.team != -1 && cmpPlayer.team != -1 && this.team != cmpPlayer.team) 720 return; 721 718 722 if (!this.SubtractResourcesOrNotify(amounts)) 719 723 return; 720 724