Skip to content

Commit

Permalink
Minor changes to MineChallenge code.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonty800 committed May 9, 2012
1 parent 985aafa commit f17787a
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 19 deletions.
1 change: 0 additions & 1 deletion ConfigGUI/ConfigGUI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
<ItemGroup>
<None Include="ChatBackground.png" />
<Content Include="ConfigGUI.ico" />
<Content Include="fcraft_config.ico" />
</ItemGroup>
<ItemGroup>
<None Include="app.config" />
Expand Down
6 changes: 3 additions & 3 deletions fCraft/Commands/Command Handlers/GunHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ public static void movePortal(object sender, PlayerMovingEventArgs e)
}
catch (Exception ex)
{
Logger.Log(LogType.SeriousError, "" + ex);
Logger.Log(LogType.SeriousError, "MovePortal: " + ex);
}
}

Expand Down Expand Up @@ -399,7 +399,7 @@ public static void changedWorld(object sender, PlayerJoinedWorldEventArgs e)
}
catch (Exception ex)
{
Logger.Log(LogType.SeriousError, "" + ex);
Logger.Log(LogType.SeriousError, "GunPortalChangeWorld: " + ex);
}
}

Expand Down Expand Up @@ -453,7 +453,7 @@ public static void playerDisconnected(object sender, PlayerDisconnectedEventArgs
}
catch (Exception ex)
{
Logger.Log(LogType.SeriousError, "" + ex);
Logger.Log(LogType.SeriousError, "GunPortalDisconnected: " + ex);
}
}
public static void removal(ConcurrentDictionary<String, Vector3I> bullets, Map map)
Expand Down
8 changes: 4 additions & 4 deletions fCraft/Games/Football.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public void ClickedFootball(object sender, PlayerClickedEventArgs e)
double rSin = Math.Sin(((double)(128 - p.R) / 255) * 2 * Math.PI);
double rCos = Math.Cos(((double)(128 - p.R) / 255) * 2 * Math.PI);

ConcurrentDictionary<String, Vector3I> bullets = new ConcurrentDictionary<String, Vector3I>();
ConcurrentDictionary<String, Vector3I> balls = new ConcurrentDictionary<String, Vector3I>();
FootThread = new Thread(new ThreadStart(delegate
{
int startX = footballPos.X;
Expand All @@ -50,17 +50,17 @@ public void ClickedFootball(object sender, PlayerClickedEventArgs e)
{
break; //needs bounce... hmmm
}
foreach (Vector3I bp in bullets.Values)
foreach (Vector3I bp in balls.Values)
{
world.Map.QueueUpdate(new BlockUpdate(null,
(short)bp.X,
(short)bp.Y,
(short)bp.Z,
Block.Air));
Vector3I removed;
bullets.TryRemove(bp.ToString(), out removed);
balls.TryRemove(bp.ToString(), out removed);
}
bullets.TryAdd(new Vector3I(pos.X, pos.Y, pos.Z).ToString(), new Vector3I(pos.X, pos.Y, pos.Z));
balls.TryAdd(new Vector3I(pos.X, pos.Y, pos.Z).ToString(), new Vector3I(pos.X, pos.Y, pos.Z));
drawFootball(new Vector3I(pos.X, pos.Y, pos.Z));
Thread.Sleep(80);
}
Expand Down
29 changes: 21 additions & 8 deletions fCraft/Games/MineChallenge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@ public class MineChallenge
public static ConcurrentDictionary<String, Vector3I> randomBlocks = new ConcurrentDictionary<string, Vector3I>();
public static List<Player> completed = new List<Player>();
public static int answer = 0;
public static GameMode mode = GameMode.NULL;

public enum GameMode
{
math1,
math2,
getOffGrass,
pinkplatform,
shootblack,
NULL
}

//init
public static void Init(World world_)
Expand All @@ -28,7 +39,7 @@ public static void Init(World world_)
Player.JoinedWorld += WorldChanging;
Player.Clicked += playerClicking;
world.Games = new List<Action>();
world.CurrentGame = null;
mode = GameMode.NULL;
redRoundsWon = 0;
blueRoundsWon = 0;
}
Expand All @@ -40,7 +51,7 @@ public static void math1()
world.Games.Remove(math1);
world.Players.Message("&WKeyboards at the ready...");
Thread.Sleep(5000);
world.CurrentGame = "math1";
mode = GameMode.math1;
int a = new Random().Next(1, 15);
int b = new Random().Next(1, 15);
world.Players.Message("&WWhat is... {0} X {1}?", a.ToString(), b.ToString());
Expand All @@ -59,7 +70,7 @@ public static void math2()
world.Games.Remove(math2);
world.Players.Message("&WKeyboards at the ready... stuff is about to happen!");
Thread.Sleep(5000);
world.CurrentGame = "math2";
mode = GameMode.math2;
int a = new Random().Next(1, 100);
int b = new Random().Next(1, 200);
world.Players.Message("&WWhat is... {0} + {1}?", a.ToString(), b.ToString());
Expand All @@ -76,7 +87,7 @@ public static void math2()
public static void getOffGrass()
{
world.Games.Remove(getOffGrass);
world.CurrentGame = "getOffGrass";
mode = GameMode.getOffGrass;
Map map = world.Map;
world.Players.Message("&WKEEP OFF THE GRASS!!!");
wait(6000);
Expand Down Expand Up @@ -110,7 +121,7 @@ public static void getOffGrass()
public static void pinkPlatform()
{
world.Games.Remove(pinkPlatform);
world.CurrentGame = "pinkPlatform";
mode = GameMode.pinkplatform;
Map map = world.Map;
int startX = ((map.Bounds.XMin + map.Bounds.XMax) / 2) + new Random().Next(10, 50);
int startY = ((map.Bounds.YMin + map.Bounds.YMax) / 2) + new Random().Next(10, 50);
Expand Down Expand Up @@ -144,7 +155,7 @@ public static void pinkPlatform()
public static void shootBlack()
{
world.Games.Remove(shootBlack);
world.CurrentGame = "shootBlack";
mode = GameMode.shootblack;
GunModeOn();
foreach (Player p in world.Players)
{
Expand Down Expand Up @@ -179,7 +190,7 @@ public static void playerClicking(object sender, PlayerClickedEventArgs e)
{
if (e.Player.World.GameOn)
{
if (e.Player.World.CurrentGame != null)
if (Games.MineChallenge.mode == Games.MineChallenge.GameMode.NULL)
{
if (platform.Values.Count > 0)
{
Expand Down Expand Up @@ -268,6 +279,7 @@ public static void teamNotify()
}
}
}

public static void GameAdder(World world)
{
world.Games.Add(pinkPlatform);
Expand Down Expand Up @@ -390,6 +402,7 @@ public static void Stop(Player player)
GameThread.Abort();
}

//needs a rewrite for new gun code
public static void GunModeOn()
{
foreach (Player player in world.Players)
Expand Down Expand Up @@ -420,7 +433,7 @@ public static void Clear()
blueRoundsWon = 0;
redRoundsWon = 0;
completed.Clear();
world.CurrentGame = null;
mode = GameMode.NULL;
}
}
}
4 changes: 2 additions & 2 deletions fCraft/Player/Chat.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static bool SendGlobal( [NotNull] Player player, [NotNull] string rawMess
{
if (player.World.GameOn)
{
if (player.World.CurrentGame == "math1")
if (Games.MineChallenge.mode == Games.MineChallenge.GameMode.math1)
{
if (rawMessage == Games.MineChallenge.answer.ToString() && !Games.MineChallenge.completed.Contains(player))
{
Expand All @@ -123,7 +123,7 @@ public static bool SendGlobal( [NotNull] Player player, [NotNull] string rawMess
return false;
}

if (player.World.CurrentGame == "math2")
if (Games.MineChallenge.mode == Games.MineChallenge.GameMode.math2)
{
if (rawMessage == Games.MineChallenge.answer.ToString() && !Games.MineChallenge.completed.Contains(player))
{
Expand Down
1 change: 0 additions & 1 deletion fCraft/World/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public sealed class World : IClassy {
public int blueScore = 0;
public List<Action> Games;
public bool GameOn = false;
public string CurrentGame;


/// <summary> Whether this world is currently pending unload
Expand Down

0 comments on commit f17787a

Please sign in to comment.