Skip to content
This repository has been archived by the owner on Jul 27, 2018. It is now read-only.

Commit

Permalink
Merge branch 'master' of github.com:Cyl18/CardSharp
Browse files Browse the repository at this point in the history
  • Loading branch information
LasmGratel committed Mar 20, 2018
2 parents 8061b5b + f46d0cd commit 0b966fd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 15 deletions.
1 change: 1 addition & 0 deletions CardSharp/CardSharp.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Numerics" />
<Reference Include="System.ValueTuple, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51, processorArchitecture=MSIL">
<HintPath>..\packages\System.ValueTuple.4.3.0\lib\netstandard1.0\System.ValueTuple.dll</HintPath>
</Reference>
Expand Down
4 changes: 2 additions & 2 deletions CardSharp/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ public class Constants
public const int AmountCardNum = 4; /*每种牌4张*/
public const int MaxPlayer = 3; /*最多3人*/
public const string ConfigDir = "CardSharp";
public const int PointAdd = 10000;
public const int BaseScore = 1000;
public const long PointAdd = 10000;
public const long BaseScore = 1000;
public const int BoardcastCardNumThreshold = 5;

public class Cards
Expand Down
6 changes: 3 additions & 3 deletions CardSharp/GameComponents/Desk.cs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ public void FinishGame(Player player)
{
AddMessageLine("SDDC duel done.");

int result = 0;
long result = 0;
switch (player.Type) {
case PlayerType.Farmer:
AddMessageLine("Winners are farmers.");
Expand Down Expand Up @@ -317,7 +317,7 @@ public void FinishGame(Player player)
FinishGame(true);
}

private int SaveSddc(IEnumerable<Player> winners, IEnumerable<Player> losers)
private long SaveSddc(IEnumerable<Player> winners, IEnumerable<Player> losers)
{
var winnersConfig = winners.Select(PlayerConfig.GetConfig).ToList();
var losersConfig = losers.Select(PlayerConfig.GetConfig).ToList();
Expand All @@ -331,7 +331,7 @@ private int SaveSddc(IEnumerable<Player> winners, IEnumerable<Player> losers)
return score;
}

private void SaveScore(PlayerConfig p, int value)
private void SaveScore(PlayerConfig p, long value)
{
var playerConf = p;
playerConf.Point = value;
Expand Down
5 changes: 4 additions & 1 deletion CardSharp/GameComponents/IPlayerConfig.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
using System;
using System.Numerics;
using Newtonsoft.Json;

namespace CardSharp.GameComponents
{
public interface IPlayerConfig
{
DateTime LastTime { get; set; }
int Point { get; set; }
long Point { get; set; }
string PlayerID { get; }
bool IsAdmin { get; }
}

}
4 changes: 2 additions & 2 deletions CardSharp/GameComponents/Multiplier.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ public static void Multiplie(Desk desk, IRule rule)
}
}

public static int CalcResult(Desk desk)
public static long CalcResult(Desk desk)
{
return (int) Math.Pow(2, desk.Multiplier) * Constants.BaseScore;
return (long) Math.Pow(2, desk.Multiplier) * Constants.BaseScore;
}
}
}
4 changes: 2 additions & 2 deletions CardSharp/GameComponents/PlayerConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ static PlayerConfig()
if (!Directory.Exists(Constants.ConfigDir)) Directory.CreateDirectory(Constants.ConfigDir);
}

public PlayerConfig(string playerid, int point = default, DateTime lastTime = default, bool isAdmin = default )
public PlayerConfig(string playerid, long point = default, DateTime lastTime = default, bool isAdmin = default )
{
PlayerID = playerid ?? throw new ArgumentNullException(nameof(playerid));
Point = point;
Expand All @@ -19,7 +19,7 @@ static PlayerConfig()
}

public string PlayerID { get; }
public int Point { get; set; }
public long Point { get; set; }
public DateTime LastTime { get; set; }

private bool _isAdmin = false;
Expand Down
10 changes: 5 additions & 5 deletions CardSharp/GameSteps/WaitingParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ public void Parse(Desk desk, Player player, string command)
case "上桌":
case "fork table":
case "法克忒薄": // By Charlie Jiang
//var point = PlayerConfig.GetConfig(player).Point;
//if (point <= 0)
// desk.AddMessage($"你的积分不足以进行游戏! 你现在有{point}点积分.");
//else
var point = PlayerConfig.GetConfig(player).Point;
if (point <= -100000)
desk.AddMessage($"CNM 这里是CY 你们的印钞厂停业了.");
else
desk.AddPlayer(player);
break;
case "下桌":
Expand All @@ -41,7 +41,7 @@ public void Parse(Desk desk, Player player, string command)
break;
}

if (command.StartsWith("开始游戏 "))
if (command.StartsWith("开始游戏 ") && PlayerConfig.GetConfig(player).IsAdmin)
{
var seed = int.Parse(command.Substring(5));
if (desk.PlayerList.Count == 3)
Expand Down

0 comments on commit 0b966fd

Please sign in to comment.