本文整理匯總了C#中SevenWondersGUI.PlayerState.getName方法的典型用法代碼示例。如果您正苦於以下問題:C# PlayerState.getName方法的具體用法?C# PlayerState.getName怎麽用?C# PlayerState.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類SevenWondersGUI.PlayerState
的用法示例。
在下文中一共展示了PlayerState.getName方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: tradeTo
//trade card to player
public void tradeTo(PlayerState p, int resourceIndex, int player){
int coinAmount = 2;
int[] tradingPostCardNumber = new int[2]{0,0};
if (resourceIndex > 6)
{
System.Console.WriteLine("resourceIndex over 6");
return;
}
PlayerState TradeTo = null;
//Set TradetoPlayer : player = 0, left, else right
if (player == 0)
{
TradeTo = gameState.getLeftPlayer(p);
tradingPostCardNumber[0] = 33;
tradingPostCardNumber[1] = 34;
}
else if (player == 1)
{
TradeTo = gameState.getRightPlayer(p);
tradingPostCardNumber[0] = 31;
tradingPostCardNumber[1] = 32;
}
//Commerce Trading Exceptions
for (int i = 0; i < ComCards[p.getName()].Count; i++)
{
//Market Card
if ((resourceIndex > 3) && ((ComCards[p.getName()][i].getNumber() == 35) || (ComCards[p.getName()][i].getNumber() == 36))) { coinAmount = 1; }
//Trading Post
if ((resourceIndex < 4) && ((ComCards[p.getName()][i].getNumber() == tradingPostCardNumber[0]) || (ComCards[p.getName()][i].getNumber() == tradingPostCardNumber[1]))) { coinAmount = 1; }
}
//1. Check for resource in base
if (baseResources[TradeTo.getName()][resourceIndex] > 0) {
coinTransactions[player] += coinAmount;
TempResources[p.getName()][resourceIndex]++;
TempResources[TradeTo.getName()][resourceIndex]--;
System.Console.WriteLine("Traded from Base Resource.");
}
//2. Then check resource in SR
else if(SpecialResourceArray(TradeTo.getName())[resourceIndex] > 0){
coinTransactions[player] += coinAmount;
TempResources[p.getName()][resourceIndex]++;
usingSpecialResource(TradeTo, resourceIndex);
System.Console.WriteLine("Traded from Special Resource.");
}
//3. Profit
else { System.Console.WriteLine("Error, no such resource available."); }
}
示例2: DisplayPlayersResources
public void DisplayPlayersResources(PlayerState p, Dictionary<string, List<int>> hashtable)
{
if (Log(p))
{
List<int> playersResources = hashtable[p.getName()];
Console.Write ("[{0}] Player [{1}] Has : ", _class.GetType().Name, p.getName());
for (int index = 0; index < playersResources.Count; index++)
{
Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), playersResources[index]);
}
Console.WriteLine();
}
}
示例3: resetSpecialResourceSingular
public void resetSpecialResourceSingular(PlayerState p)
{
List<ResourceCard> tempList = new List<ResourceCard>();
for (int i = 0; i < p.getPlayedCards().Count; i++)
{
if (p.getPlayedCards()[i].getType() < 3)
{
ResourceCard c = (ResourceCard)p.getPlayedCards()[i];
if (((c.getNumber() > 7) && (c.getNumber() < 14)))
{
tempList.Add(c);
}
}
}
SResources[p.getName()] = tempList;
}
開發者ID:sunneh,項目名稱:7Wonders,代碼行數:20,代碼來源:ResourceManager+(Scott+Needham's+conflicted+copy+2013-04-05).cs
示例4: UpdateResources
private void UpdateResources(PlayerState p, Card c)
{
//_logger.UpdatingPlayersResources(p,c);
//_logger.DisplayResourceCost(p,c);
if (c is CommerceCard)
{
KensUtilityfunctions k = new KensUtilityfunctions();
int income = k.calcCommerceIncome(c, gameState, p.getSeatNumber());
p.updateCoins(income);
return;
}
if (c is ResourceCard)
{
//_logger.CheckResourceCard(p,c);
//_logger.DisplayPlayersResources(p, hashtable);
List<int> current = baseResources[p.getName()];
if (((ResourceCard)c).hasTradableResources())
{
if ((((ResourceCard)c).getNumber() > 7) && (((ResourceCard)c).getNumber() < 14))
{
//populate Special Resource Hashmap if the Card is a special resource
List<ResourceCard> srlst = SResources[p.getName()];
srlst.Add((ResourceCard)c);
SResources[p.getName()] = srlst;
System.Console.WriteLine(p.getName() + " is adding Special Resource Card: {" + ((ResourceCard)c).getResources()[0] + "," + ((ResourceCard)c).getResources()[1] + "," + ((ResourceCard)c).getResources()[2] + "," + ((ResourceCard)c).getResources()[3] + "," + ((ResourceCard)c).getResources()[4] + "," + ((ResourceCard)c).getResources()[5] + "," + ((ResourceCard)c).getResources()[6] + "}");
}
else
{
int[] tradableResources = ((ResourceCard)c).getResources();
for (int index = 0; index < tradableResources.Count(); index++)
{
switch (index)
{
case (int)Resource.Wood:
current[(int)Resource.Wood] += tradableResources[index];
break;
case (int)Resource.Stone:
current[(int)Resource.Stone] += tradableResources[index];
break;
case (int)Resource.Clay:
current[(int)Resource.Clay] += tradableResources[index];
break;
case (int)Resource.Ore:
current[(int)Resource.Ore] += tradableResources[index];
break;
case (int)Resource.Glass:
current[(int)Resource.Glass] += tradableResources[index];
break;
case (int)Resource.Loom:
current[(int)Resource.Loom] += tradableResources[index];
break;
case (int)Resource.Paper:
current[(int)Resource.Paper] += tradableResources[index];
break;
}
}
System.Console.WriteLine(p.getName() +" is adding: {" + tradableResources[0] + "," + tradableResources[1] + "," + tradableResources[2] + "," + tradableResources[3] + "," + tradableResources[4] + "," + tradableResources[5] + "," + tradableResources[6] + "}");
baseResources[p.getName()] = current;
//_logger.DisplayPlayersResources(p, hashtable);
}
}
return;
}
//_logger.CheckDictionary(p,hashtable);
//_logger.DisplayPlayersResources(p, hashtable);
}
開發者ID:sunneh,項目名稱:7Wonders,代碼行數:71,代碼來源:ResourceManager+(Scott+Needham's+conflicted+copy+2013-04-05).cs
示例5: Resources
//returns the base resources
/*public Resources GetResources(PlayerState p)
{
List<int> l = baseResources[gameState.getLeftPlayer(p).getName()];
List<int> r = baseResources[gameState.getRightPlayer(p).getName()];
List<int> c = baseResources[p.getName()];
// Get the wonder boards default resources
//_logger.CheckWonderBoard(p);
return new Resources(l.ToArray(), r.ToArray(), c.ToArray(), p.getName());
}*/
/*
* Input: A Player
*
*
* Output: Resources Object -> Given the player object, what are the total available resources
* adding both chosen special resources and base resources?
*/
public Resources GetCombinedResources(PlayerState p)
{
List<int> l = new List<int>();
List<int> r = new List<int>();
List<int> c = new List<int>();
for (int i = 0; i < 7; i++)
{
l.Add(baseResources[gameState.getLeftPlayer(p).getName()][i]
+ TempResources[gameState.getLeftPlayer(p).getName()][i]);
r.Add(baseResources[gameState.getRightPlayer(p).getName()][i]
+ TempResources[gameState.getRightPlayer(p).getName()][i]);
c.Add(baseResources[p.getName()][i] + TempResources[p.getName()][i]);
}
// Get the wonder boards default resources
//_logger.CheckWonderBoard(p);
int[] br = p.getBoard().getResources();
for (int i = 0; i < br.Count(); i++)
c[i] = (br[i] + c[i]);
// Now lets get any speical resources the player may have
//List<ResourceCard> sr = SResources[p.getName()];
//for (int i = 0; i < sr.Count(); i++)
//{
// ResourceCard rc = sr[i];
// int[] resources = rc.getResources();
// for (int index = 0; index < resources.Count(); index++)
// c[index] = (c[index] + resources[index]);
//}
return new Resources(l.ToArray(), r.ToArray(), c.ToArray(), p.getName());
}
示例6: tradableArray
public int[] tradableArray(PlayerState p, int lr) {
PlayerState player = null;
int[] tradeTable = new int[7] { 0, 0, 0, 0, 0, 0, 0 };
switch (lr)
{
case 0:
player = p;
break;
case 1:
player = gameState.getLeftPlayer(p);
break;
case 2:
player = gameState.getLeftPlayer(p);
break;
}
int[] boardResources = p.getBoard().getResources();
for (int i = 0; i < 7; i++)
{
tradeTable[i] = SpecialResourceArray(player.getName())[i]
+ baseResources[player.getName()][i]
+ TempResources[player.getName()][i]
+ boardResources[i];
}
return tradeTable;
}
示例7: resetCommerceCards
//Missing Code in this Function
public void resetCommerceCards(PlayerState p) {
List<CommerceCard> tempList = new List<CommerceCard>();
for (int i = 0; i < p.getPlayedCards().Count; i++)
{
if (p.getPlayedCards()[i].getType() == 4)
{
CommerceCard c = (CommerceCard)p.getPlayedCards()[i];
if (((c.getNumber() > 30) && (c.getNumber() < 37)) || ((c.getNumber() > 70) && (c.getNumber() < 77)))
{
tempList.Add(c);
}
}
}
ComCards[p.getName()] = tempList;
}
示例8: LogPlayer
public void LogPlayer(int index)
{
player = _gameState.getPlayers()[index];
_playerName = player.getName();
}
示例9: CheckResourceCost
public bool CheckResourceCost(PlayerState p, Card c)
{
int[] totalResources = { 0, 0, 0, 0, 0, 0, 0 };
int[] cost = c.getCost();
int[] boardResources = p.getBoard().getResources();
List<int> playersResources = hashtable[p.getName()];
for (int i = 0; i < playersResources.Count(); i++)
{
totalResources[i] = (playersResources[i] + boardResources[i]);
}
var resources = Enum.GetValues(typeof(Resource));
foreach (var type in resources)
{
int resource = (int)type;
if (cost[resource] > totalResources[resource])
return false;
}
return true;
}
示例10: validateTrade
/*
* Input: A Player, a Card and a direction(0 = right, 1 = left)
*
*
* Output: number of coins required to trade for resources for card with the player
* at the given direction. negitive number if impossible
*/
public int validateTrade(PlayerState p, Card c, int direction)
{
int recCost = 2;
int comCost = 2;
//checkes to see if a player can play card with thier own resources
if (ValidateCard(p, c))
{
return 0;
}
PlayerState trader;
if ((p.getBoard().getName().Equals("WB10")
&& (p.getBoard().getCurrentWonderLevel() >= 1)))
{
recCost = 1;
}
if (direction == 0)
{
trader = gameState.getRightPlayer(p);
for (int i = 0; i < p.getPlayedCards().Count; i++)
{
if ((p.getPlayedCards()[i].getNumber() == 31) ||
(p.getPlayedCards()[i].getNumber() == 32))
{
recCost = 1;
break;
}
}
}
else
{
trader = gameState.getLeftPlayer(p);
for (int i = 0; i < p.getPlayedCards().Count; i++)
{
if ((p.getPlayedCards()[i].getNumber() == 33) ||
(p.getPlayedCards()[i].getNumber() == 34))
{
recCost = 1;
break;
}
}
}
for (int i = 0; i < p.getPlayedCards().Count; i++)
{
if ((p.getPlayedCards()[i].getNumber() == 35) ||
(p.getPlayedCards()[i].getNumber() == 36))
{
comCost = 1;
}
}
if (!baseResources.ContainsKey(trader.getName()))
{
return -1;
}
int cost = 0;
List<int> traderResources = baseResources[trader.getName()];
int[] requiredResources = new int[c.getCost().Length];
for (int i = 0; i < c.getCost().Length; i++)
{
requiredResources[i] = c.getCost()[i];
requiredResources[i] -= baseResources[p.getName()][i];//p.getResources()[i];
if (requiredResources[i] < 0)
{
requiredResources[i] = 0;
}
if (traderResources[i] < requiredResources[i])
{
return -1;
}
if (i < 4)
{
cost += requiredResources[i] * recCost;
}
else
{
cost += requiredResources[i] * comCost;
}
Console.WriteLine("cost " + cost + " cur rec " + requiredResources[i]);
}
return cost;
}
示例11: UpdateResources
private void UpdateResources(PlayerState p, Card c)
{
//_logger.UpdatingPlayersResources(p,c);
//_logger.DisplayResourceCost(p,c);
if (c is CommerceCard)
{
//KensUtilityfunctions k = new KensUtilityfunctions();
//int income = k.calcCommerceIncome(c, gameState, p.getSeatNumber());
//p.updateCoins(income);
if (((CommerceCard)c).hasTradableResources())
{
//_logger.DisplayPlayersResources(p, hashtable);
//_logger.CheckCommerceCard(p,c);
List<int> current = hashtable[p.getName()];
int[] tradableResources = ((CommerceCard)c).getResourceTradable();
for (int index = 0; index < tradableResources.Count(); index++)
{
switch (index)
{
case (int)Resource.Wood:
current[(int)Resource.Wood] += tradableResources[index];
break;
case (int)Resource.Stone:
current[(int)Resource.Stone] += tradableResources[index];
break;
case (int)Resource.Clay:
current[(int)Resource.Clay] += tradableResources[index];
break;
case (int)Resource.Ore:
current[(int)Resource.Ore] += tradableResources[index];
break;
}
}
hashtable[p.getName()] = current;
//_logger.DisplayPlayersResources(p, hashtable);
}
return;
}
if (c is ResourceCard)
{
//_logger.CheckResourceCard(p,c);
//_logger.DisplayPlayersResources(p, hashtable);
List<int> current = hashtable[p.getName()];
if (((ResourceCard)c).hasTradableResources())
{
int[] tradableResources = ((ResourceCard)c).getResources();
for (int index = 0; index < tradableResources.Count(); index++)
{
switch (index)
{
case (int)Resource.Wood:
current[(int)Resource.Wood] += tradableResources[index];
break;
case (int)Resource.Stone:
current[(int)Resource.Stone] += tradableResources[index];
break;
case (int)Resource.Clay:
current[(int)Resource.Clay] += tradableResources[index];
break;
case (int)Resource.Ore:
current[(int)Resource.Ore] += tradableResources[index];
break;
case (int)Resource.Glass:
current[(int)Resource.Glass] += tradableResources[index];
break;
case (int)Resource.Loom:
current[(int)Resource.Loom] += tradableResources[index];
break;
case (int)Resource.Paper:
current[(int)Resource.Paper] += tradableResources[index];
break;
}
}
hashtable[p.getName()] = current;
//_logger.DisplayPlayersResources(p, hashtable);
}
return;
}
//_logger.CheckDictionary(p,hashtable);
//_logger.DisplayPlayersResources(p, hashtable);
}
示例12: GetResources
public Resources GetResources(PlayerState p)
{
List<int> l = hashtable[gameState.getLeftPlayer(p).getName()];
List<int> r = hashtable[gameState.getRightPlayer(p).getName()];
List<int> c = hashtable[p.getName()];
// Get the wonder boards default resources
//_logger.CheckWonderBoard(p);
if (boardRAdded == false)
{
int[] br = p.getBoard().getResources();
for (int i = 0; i < br.Count(); i++)
c[i] = (br[i] + c[i]);
boardRAdded = true;
}
return new Resources(l.ToArray(), r.ToArray(), c.ToArray(), p.getName());
}
示例13: CheckResourceCost
//Returns true if the player can afford the cost
public bool CheckResourceCost(PlayerState p, int[] cost)
{
int[] totalResources = { 0, 0, 0, 0, 0, 0, 0 };
if (!canAfford(p)) { return false; }
List<int> playersResources = baseResources[p.getName()];
List<int> tempR = TempResources[p.getName()];
for (int i = 0; i < playersResources.Count(); i++)
{
totalResources[i] = playersResources[i] + tempR[i];
}
if(p.getName().Equals("P0")){
System.Console.WriteLine(p.getName() + ":CheckResourceCost:COST:{" + cost[0] + "," + cost[1] + "," + cost[2] + "," + cost[3] + "," + cost[4] + "," + cost[5] + "," + cost[6] + "}");
System.Console.WriteLine(p.getName() + ":CheckResourceCost:AVAI:{" + totalResources[0] + "," + totalResources[1] + "," + totalResources[2] + "," + totalResources[3] + "," + totalResources[4] + "," + totalResources[5] + "," + totalResources[6] + "}");
}
for (int i = 0; i < playersResources.Count(); i++)
{
if (totalResources[i] < cost[i])
{
return false;
}
}
/*var resources = Enum.GetValues(typeof(Resource));
foreach (var type in resources)
{
int resource = (int)type;
if (cost[resource] > totalResources[resource])
return false;
}*/
coinExchange(p);
resetResources(p);
return true;
}
示例14: ValidatingCard
public void ValidatingCard(PlayerState p, Card c)
{
if (Log(p))
{
System.Console.WriteLine("\n\n=============================================================================================================");
System.Console.WriteLine("{0}:: \nValidateCard( Player [{1}] Card [{2}] Coin Cost [{3}] Resource Cost [{4}])"
, _class.GetType().Name
, p.getName()
, c.getName()
, c.getCoinCost()
, c.getTotalResourceCost());
System.Console.WriteLine("=============================================================================================================");
}
}
示例15: resetTempResources
/*
* Input: A Player
*
* Output: void -> Given a player, This is the helper function to resetResources.
* This clears the temp resource of a player.
*/
public void resetTempResources(PlayerState p) {
List<int> temp = new List<int>();
for(int i = 0; i<7 ; i++) {temp.Add(0);}
TempResources[p.getName()] = temp;
}