本文整理汇总了C#中db.Database.UpdateFortuneToken方法的典型用法代码示例。如果您正苦于以下问题:C# Database.UpdateFortuneToken方法的具体用法?C# Database.UpdateFortuneToken怎么用?C# Database.UpdateFortuneToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类db.Database
的用法示例。
在下文中一共展示了Database.UpdateFortuneToken方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HandleRequest
//.........这里部分代码省略.........
List<int> items = Utils.FromCommaSepString32(rdr.GetString("contents")).ToList();
List<int> candidates = new List<int>(3);
do
{
int item = items[rand.Next(items.Count)];
if (!candidates.Contains(item))
candidates.Add(item);
} while (candidates.Count < 3);
if (currency == GOLD)
{
if (Query["status"] == "0")
{
if (CurrentGames.ContainsKey(acc.AccountId))
CurrentGames.Remove(acc.AccountId);
CurrentGames.Add(acc.AccountId, candidates.ToArray());
price = rdr.GetInt32("priceFirstInGold");
status = "<Success><Candidates>" +
Utils.GetCommaSepString(candidates.ToArray()) +
"</Candidates><Gold>" +
(acc.Credits - price) +
"</Gold></Success>";
}
else if (Query["status"] == "1")
{
if (CurrentGames.ContainsKey(acc.AccountId))
{
candidates = CurrentGames[acc.AccountId].ToList();
candidates.Shuffle();
status = "<Success><Awards>" + candidates[int.Parse(Query["choice"])] + "</Awards></Success>";
gifts.Add(candidates[int.Parse(Query["choice"])]);
candidates.Remove(candidates[int.Parse(Query["choice"])]);
CurrentGames[acc.AccountId] = candidates.ToArray();
}
}
else if (Query["status"] == "2")
{
if (CurrentGames.ContainsKey(acc.AccountId))
{
candidates = CurrentGames[acc.AccountId].ToList();
candidates.Shuffle();
price = rdr.GetInt32("priceSecondInGold");
status = "<Success><Awards>" + candidates[int.Parse(Query["choice"])] + "</Awards></Success>";
gifts.Add(candidates[int.Parse(Query["choice"])]);
CurrentGames.Remove(acc.AccountId);
}
}
}
else if (currency == FORTUNETOKENS)
{
if (Query["status"] == "0")
{
if (CurrentGames.ContainsKey(acc.AccountId))
CurrentGames.Remove(acc.AccountId);
CurrentGames.Add(acc.AccountId, candidates.ToArray());
price = rdr.GetInt32("priceFirstInToken");
status = "<Success><Candidates>" +
Utils.GetCommaSepString(candidates.ToArray()) +
"</Candidates><FortuneToken>" +
(acc.FortuneTokens - price) +
"</FortuneToken></Success>";
}
else if (Query["status"] == "1")
{
if (CurrentGames.ContainsKey(acc.AccountId))
{
candidates = CurrentGames[acc.AccountId].ToList();
candidates.Shuffle();
status = "<Success><Awards>" + candidates[int.Parse(Query["choice"])] + "</Awards></Success>";
gifts.Add(candidates[int.Parse(Query["choice"])]);
candidates.Remove(candidates[int.Parse(Query["choice"])]);
CurrentGames[acc.AccountId] = candidates.ToArray();
}
}
else if (Query["status"] == "2")
{
status = "<Error>You can not play twiche with a Fortune Token</Error>";
}
}
else
status = "<Error>Invalid currency</Error>";
}
else
status = "<Error>Invalid gameId</Error>";
}
if (currency == GOLD)
db.UpdateCredit(acc, price == -1 ? 0 : -price);
else if (currency == FORTUNETOKENS)
db.UpdateFortuneToken(acc, price == -1 ? 0 : -price);
db.AddGifts(acc, gifts);
}
else
status = "<Error>Account not found</Error>";
using (StreamWriter wtr = new StreamWriter(Context.Response.OutputStream))
wtr.Write(status);
}
}