public OLobbyRoom CreateLobby(OPlayer host) { var maxLobId = (from lobMaxId in dc.Lobbies select lobMaxId.LobbyId).Max(); Lobby lobby = new Lobby(); lobby.LobbyName = host.PlayerName + "'s lobby"; lobby.LobbyId = ++maxLobId; lobby.IsWaitingForPlayers = true; lobby.IsUpdate = false; lobby.DiceRollllllllllllllllllllol = 0; PlayLobby pLobby = new PlayLobby(); pLobby.HostPlayer = host.PlayerId; pLobby.LobbyId = lobby.LobbyId; pLobby.PlayerId = host.PlayerId; dc.PlayLobbies.InsertOnSubmit(pLobby); dc.Lobbies.InsertOnSubmit(lobby); dc.SubmitChanges(); return new OLobbyRoom { HostPlayer = host, PlayerList = new List<OPlayer> { host }, TheLobby = new OLobby { LobbyId = lobby.LobbyId, LobbyName = lobby.LobbyName, IsUpdate = false } }; }
/// <summary> /// Gets the pattern for palyer 'p' on 'playnumber'. /// </summary> /// <param name="p"></param> /// <param name="playNumber"></param> /// <returns></returns> public string GetOPattern( OPlayer p, int playNumber) { int patternLoc = GetOPatternLocation(p, playNumber); //TODO: write this function return ""; }
public int[] GetPlayerFormationPoint(int formationNumber, OPlayer p) { int[] ret = new int[4]; byte hi = 0; byte lo = 0; int pointerLoc = formationNumber*22 + FORMATION_POINTER_STARTING_INDEX+((int)p*2); hi = MainForm.TheROM[pointerLoc+1]; lo = MainForm.TheROM[pointerLoc]; int playerYXloc = lo + (hi * 0x100) - 0x2000 + 0x10; // sbyte tmp =0; // tmp = (sbyte)MainForm.TheROM[playerYXloc+1]; // x // ret[0] = tmp; // tmp = (sbyte)MainForm.TheROM[playerYXloc]; // y // ret[1] = -tmp; ret[0] = MainForm.TheROM[playerYXloc]; ret[1] = MainForm.TheROM[playerYXloc+1]; ret[2] = MainForm.TheROM[playerYXloc+2]; ret[3] = MainForm.TheROM[playerYXloc+3]; return ret; }
/// <summary> /// Gets the pointer location for a player's pattern. /// Result is absolute location in ROM (not relative). /// </summary> /// <param name="p"></param> /// <param name="playNumber"></param> /// <returns></returns> public int GetOPatternLocation( OPlayer p, int playNumber) { int playerPointer = OFFENSIVE_PLAY_POINTERS + (playNumber*22) + ((int)p*2); byte lowByte, hiByte; lowByte = MainForm.TheROM[playerPointer]; hiByte = MainForm.TheROM[playerPointer+1]; int patternLoc = lowByte + (hiByte * 255 ) - 0x2000 + 0x10; return patternLoc; }
/// <summary> /// Sets the pointer for player p on 'playNumber' to 'pointer'. /// </summary> /// <param name="p"></param> /// <param name="playNumber"></param> /// <param name="pointer"></param> public void SetOPatternLocationRelative(OPlayer p, int playNumber, byte[] pointer) { if( pointer != null && pointer.Length > 1 ) { int playerPointer = OFFENSIVE_PLAY_POINTERS + (playNumber*22) + ((int)p * 2); MainForm.TheROM[playerPointer] = pointer[0]; MainForm.TheROM[playerPointer+1] = pointer[1]; } else { MessageBox.Show("Argument Error with SetOPatternLocationRelative 'byte[]'"); } }
/// <summary> /// Sets the pointer for player p on 'playNumber' to 'pointer'. /// </summary> /// <param name="p"></param> /// <param name="playNumber"></param> /// <param name="pointer"></param> public void SetOPatternLocationRelative(OPlayer p, int playNumber, string pointer) { try { int stuff = Int32.Parse(pointer,System.Globalization.NumberStyles.AllowHexSpecifier); byte[] bytes = new byte[2]; byte hi = (byte)(stuff >> 8); byte lo = (byte)(stuff & 0x00ff); bytes[1] = hi; bytes[0] = lo; // ret[0] = hiByte; // ret[1] = lowByte; SetOPatternLocationRelative(p, playNumber, bytes); } catch(Exception ex ) { MessageBox.Show(string.Format( "ERROR! {0}\nCould not set pointer on play {1} for position {2}\n{3}", ex.Message, playNumber, p, ex.StackTrace)); } }
/// <summary> /// Gets a string representation of the pointer for the given player on /// the given play. /// </summary> /// <param name="p"></param> /// <param name="playNumber"></param> /// <returns></returns> public string GetOPatternLocationRelativeStr(OPlayer p, int playNumber) { string result = null; byte[] pointer = GetOPatternLocationRelative(p,playNumber); if( pointer != null && pointer.Length > 1) { result = string.Format("{0:x2}{1:x2}",pointer[0],pointer[1]); } return result; }
/// <summary> /// Gets the 2 bytes that comprise a player's pattern pointer (relative address). /// [ loByte, hiByte ] /// </summary> /// <param name="p"></param> /// <param name="playNumber"></param> /// <returns></returns> public byte[] GetOPatternLocationRelative(OPlayer p, int playNumber) { int playerPointer = OFFENSIVE_PLAY_POINTERS + (playNumber*22) + ((int)p * 2); byte lowByte, hiByte; lowByte = MainForm.TheROM[playerPointer]; hiByte = MainForm.TheROM[playerPointer+1]; byte[] ret = new byte[2]; // ret[0] = lowByte; // ret[1] = hiByte; ret[0] = hiByte; ret[1] = lowByte; return ret; //byte ret = MainForm.TheROM[playerPointer]; //return ret; }