Skip to content

Commit

Permalink
🔖 1.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
kyechan99 committed Jul 24, 2017
1 parent 21eb4ea commit 5e2dbfc
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 43 deletions.
2 changes: 1 addition & 1 deletion Script/Server.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Server
public static List<User> v_user = new List<User>();
public static int userIdx = 0;
public static ManualResetEvent allDone = new ManualResetEvent(false);
public static string version = "1.2.0";
public static string version = "1.2.1";

/**
* @brief 초기화
Expand Down
108 changes: 66 additions & 42 deletions Script/User/User.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,57 +416,81 @@ static void StartGame()
if (Server.v_user[i] != null)
memCount++;

int police = memCount / 3;
int thief = memCount - police;
PROPER[] proArr = new PROPER[memCount];

for (int i = 0; i < memCount / 3; i++)
proArr[i] = PROPER.POLICE;
for (int i = 0; i < memCount - (memCount / 3); i++)
proArr[(memCount / 3) + i] = PROPER.THIEF;

int mIdx = 0;
for (int i = 0; i < Server.v_user.Count; i++)
{
int colorT = Server.rand.Next(0, 9);

if (Server.v_user[i] != null)
{
if (thief.Equals(0))
{
police--;
Server.v_user[i].proper = PROPER.POLICE;

for (int j = 0; j < Server.v_user.Count; j++)
if (Server.v_user[j] != null)
Server.v_user[j].SendMsg(string.Format("PROPER:{0}:{1}:{2}", Server.v_user[i].myIdx, (int)PROPER.POLICE, (int)colorT));
}
else if (police > 0)
{
if (Server.rand.Next(0, 2) == 0)
{
police--;
Server.v_user[i].proper = PROPER.POLICE;

for (int j = 0; j < Server.v_user.Count; j++)
if (Server.v_user[j] != null)
Server.v_user[j].SendMsg(string.Format("PROPER:{0}:{1}:{2}", Server.v_user[i].myIdx, (int)PROPER.POLICE, (int)colorT));
}
else
{
thief--;
Server.v_user[i].proper = PROPER.THIEF;

for (int j = 0; j < Server.v_user.Count; j++)
if (Server.v_user[j] != null)
Server.v_user[j].SendMsg(string.Format("PROPER:{0}:{1}:{2}", Server.v_user[i].myIdx, (int)PROPER.THIEF, (int)colorT));
}
}
else
{
thief--;
Server.v_user[i].proper = PROPER.THIEF;
int colorT = Server.rand.Next(0, 9);
int pIdx = Server.rand.Next(0, memCount - (mIdx++));
for (int j = 0; j < Server.v_user.Count; j++)
if (Server.v_user[j] != null)
Server.v_user[j].SendMsg(string.Format("PROPER:{0}:{1}:{2}", Server.v_user[i].myIdx, (int)proArr[pIdx], (int)colorT));

for (int j = 0; j < Server.v_user.Count; j++)
if (Server.v_user[j] != null)
Server.v_user[j].SendMsg(string.Format("PROPER:{0}:{1}:{2}", Server.v_user[i].myIdx, (int)PROPER.THIEF, (int)colorT));
}
PROPER tp = proArr[memCount - mIdx];
proArr[memCount - mIdx] = proArr[pIdx];
proArr[pIdx] = tp;
}
}

//int police = memCount / 3;
//int thief = memCount - police;

//for (int i = 0; i < Server.v_user.Count; i++)
//{
// int colorT = Server.rand.Next(0, 9);

// if (Server.v_user[i] != null)
// {
// if (thief.Equals(0))
// {
// police--;
// Server.v_user[i].proper = PROPER.POLICE;

// for (int j = 0; j < Server.v_user.Count; j++)
// if (Server.v_user[j] != null)
// Server.v_user[j].SendMsg(string.Format("PROPER:{0}:{1}:{2}", Server.v_user[i].myIdx, (int)PROPER.POLICE, (int)colorT));
// }
// else if (police > 0)
// {
// if (Server.rand.Next(0, 2) == 0)
// {
// police--;
// Server.v_user[i].proper = PROPER.POLICE;

// for (int j = 0; j < Server.v_user.Count; j++)
// if (Server.v_user[j] != null)
// Server.v_user[j].SendMsg(string.Format("PROPER:{0}:{1}:{2}", Server.v_user[i].myIdx, (int)PROPER.POLICE, (int)colorT));
// }
// else
// {
// thief--;
// Server.v_user[i].proper = PROPER.THIEF;

// for (int j = 0; j < Server.v_user.Count; j++)
// if (Server.v_user[j] != null)
// Server.v_user[j].SendMsg(string.Format("PROPER:{0}:{1}:{2}", Server.v_user[i].myIdx, (int)PROPER.THIEF, (int)colorT));
// }
// }
// else
// {
// thief--;
// Server.v_user[i].proper = PROPER.THIEF;

// for (int j = 0; j < Server.v_user.Count; j++)
// if (Server.v_user[j] != null)
// Server.v_user[j].SendMsg(string.Format("PROPER:{0}:{1}:{2}", Server.v_user[i].myIdx, (int)PROPER.THIEF, (int)colorT));
// }
// }
//}

tmr.Start();
}

Expand Down

0 comments on commit 5e2dbfc

Please sign in to comment.