public Game(IDeckFactory factory, GameID id) { ID = id; DeckFactory = factory; DrawPile = factory.CreateDefaultDrawableDeck(); DiscardPile = factory.CreateDefaultPlayableDeck(); }
/// <summary> /// Registers existing Hoard game. This game must exist on Hoard platform. /// This function performs initial setup of game contract. /// </summary> /// <param name="game">[in/out] game object must contain valid ID. Other fields will be retrieved from platform</param> /// <returns></returns> public async Task RegisterHoardGame(GameID game) { if (gameContracts.ContainsKey(game)) { ErrorCallbackProvider.ReportWarning("Game already registered!"); return; } string gameAddress = await gameCenter.GetGameContractAsync(game.ID); if (gameAddress != Eth.Utils.EMPTY_ADDRESS && gameAddress != "0x") { GameContract gameContract = new GameContract(web, gameAddress); string url = await gameContract.GetGameServerURLAsync(); game.Name = await gameContract.GetName(); game.GameOwner = await gameContract.GetOwner(); if ((url != null) && (url.Length > 0)) { game.Url = !url.StartsWith("http") ? "http://" + url : url; } gameContracts.Add(game, gameContract); return; } throw new HoardException($"Game is not registered in Hoard Game Center: game = {game.ID}!"); }
internal GameInfo GetInstalledGameFromFile(string path) { var kv = new KeyValue(); kv.ReadFileAsText(path); var name = string.Empty; if (string.IsNullOrEmpty(kv["name"].Value)) { if (kv["UserConfig"]["name"].Value != null) { name = StringExtensions.NormalizeGameName(kv["UserConfig"]["name"].Value); } } else { name = StringExtensions.NormalizeGameName(kv["name"].Value); } var gameId = new GameID(kv["appID"].AsUnsignedInteger()); var game = new GameInfo() { Source = "Steam", GameId = gameId.ToString(), Name = name, InstallDirectory = Path.Combine((new FileInfo(path)).Directory.FullName, "common", kv["installDir"].Value), PlayAction = CreatePlayTask(gameId), IsInstalled = true }; return game; }
public GameItemTests(HoardServiceFixture _hoardFixture, IPFSFixture _ipfsFixture) { hoardFixture = _hoardFixture; ipfsFixture = _ipfsFixture; try { hoardFixture.Initialize(HoardGameTestName); GameID[] games = hoardFixture.HoardService.GetAllHoardGames().Result; Assert.NotEmpty(games); GameID game = games[0]; HoardGameItemProvider hoardItemProvider = new HoardGameItemProvider(game); gameItemProvider = new BCGameItemMockProvider(game, (BCComm)hoardFixture.HoardService.BCComm); hoardItemProvider.SecureProvider = gameItemProvider; hoardFixture.HoardService.RegisterGame(game, hoardItemProvider); Assert.NotNull(gameItemProvider); DefaultPlayer = hoardFixture.UserIDs[2]; } catch (Exception) { Assert.True(false); } }
public void UploadDownloadState() { GameItem swordItem = new GameItem(GameID.FromName("test"), "TM721", null); swordItem.Properties = new SwordProperties("my sword", 10, 5, 20); GameItem[] items = gameItemProvider.GetPlayerItems(DefaultPlayer, swordItem.Symbol).Result; Assert.Equal(2, items.Length); string propsJson = JsonConvert.SerializeObject(swordItem.Properties); swordItem.State = ipfsFixture.Client.UploadAsync(Encoding.ASCII.GetBytes(propsJson)).Result; swordItem.Metadata = items[0].Metadata; gameItemProvider.UpdateItemState(swordItem, DefaultPlayer); items = gameItemProvider.GetPlayerItems(DefaultPlayer, swordItem.Symbol).Result; GameItem downloadedSwordItem = items[0]; try { hoardFixture.HoardService.FetchItemProperties(downloadedSwordItem); Assert.Equal(swordItem.State, downloadedSwordItem.State); string downloadedPropsJson = Encoding.ASCII.GetString(ipfsFixture.Client.DownloadBytesAsync(downloadedSwordItem.State).Result); SwordProperties downloadedProps = JsonConvert.DeserializeObject <SwordProperties>(downloadedPropsJson); Assert.Equal((SwordProperties)swordItem.Properties, downloadedProps); } catch (Exception) { Assert.True(false); } }
/// <summary> /// Adds a packet to the queue for serial processing. /// </summary> /// <param name="con">the connection which sent the packet</param> /// <param name="msg">the packet</param> public void AddGamePacketForProcessing(GSLobbyInboundPlayerConnection con, PacketGameMessage msg) { Action <object> lambda = (state) => { Action <ServerUser, PacketGameMessage> handler = m_PacketHandlers.GetHandlerDelegate(msg.PacketSubTypeID); if (handler != null && OnBeforeHandleGamePacket(con.ServerUser, msg)) { try { handler(con.ServerUser, msg); } catch (Exception e) { Log.LogMsg("Exception thrown whilst processing game packet type " + msg.PacketTypeID.ToString() + ", sub-type " + msg.PacketSubTypeID + ". Object = " + this.GetType().ToString() + ", Message: " + e.Message + ". Stack:\r\n " + e.StackTrace); } con.OnAfterPacketProcessed(msg); return; } con.KillConnection("Did not have a registered game packet handler for game packet. " + msg.PacketTypeID.ToString() + ", SubType " + msg.PacketSubTypeID.ToString() + ". "); }; // if we're not processing packets immediately, then this method (AddGamePacketForProcessing) is being called as part of a tight networking processing loop // which is executed serially, so we need to NOT queue the packet in that case and just run it if (!con.ProcessIncomingPacketsImmediately) { lambda(null); } else { Task t = new Task(lambda, "Game [" + GameID.ToString() + "] Process game packet " + msg.PacketSubTypeID.ToString(), TaskCreationOptions.LongRunning); m_NetQ.AddTask(t); } }
private IEnumerator RequestGetServerDataIE(string relativePath, ServerResponseCallback onResponse) { string url = REQUEST_ROOT_URL + relativePath; using (UnityWebRequest request = UnityWebRequest.Get(url)) { request.SetRequestHeader("userId", UserID); request.SetRequestHeader("scene", SceneID); request.SetRequestHeader("token", Token); request.SetRequestHeader("gameid", GameID.ToString()); request.SetRequestHeader("Content-type", "application/json; charset=utf-8"); yield return(request.SendWebRequest()); if (request.isNetworkError) { Debug.LogError(request.error); onResponse?.Invoke(false, request); } else { Debug.Log("server get callback url:" + url + "| json:" + request.downloadHandler.text); onResponse?.Invoke(true, request); } } }
private IEnumerator RequestPostServerDataIE(string relativePath, string postData, ServerResponseCallback onResponse) { string url = REQUEST_ROOT_URL + relativePath; using (UnityWebRequest request = new UnityWebRequest(url, "POST")) { request.SetRequestHeader("userId", UserID); request.SetRequestHeader("scene", SceneID); request.SetRequestHeader("token", Token); request.SetRequestHeader("gameid", GameID.ToString()); request.SetRequestHeader("Content-type", "application/json; charset=utf-8"); byte[] bodyRaw = System.Text.Encoding.UTF8.GetBytes(postData); request.uploadHandler = (UploadHandler) new UploadHandlerRaw(bodyRaw); request.downloadHandler = (DownloadHandler) new DownloadHandlerBuffer(); yield return(request.SendWebRequest()); if (request.isNetworkError) { Debug.LogError(request.error); onResponse?.Invoke(false, request); } else { Debug.Log("server post callback url:" + url + "| json:" + request.downloadHandler.text); onResponse?.Invoke(true, request); } } }
public void TestCryptoKittyProvider() { hoardFixture.InitializeFromConfig(); HoardService hoard = hoardFixture.HoardService; if (hoard.DefaultGame != GameID.kInvalidID) { ErrorCallbackProvider.ReportInfo("\tName: " + hoard.DefaultGame.Name); ErrorCallbackProvider.ReportInfo("\tBackend Url: " + hoard.DefaultGame.Url); ErrorCallbackProvider.ReportInfo("\tGameID: " + hoard.DefaultGame.ID); } //Hoard.PlayerID myId = new PlayerID("0x5d0774af3a8f7656dc61bcf30e383056275911b7",""); //Assert.True(myId != PlayerID.kInvalidID, "ERROR: Invalid player ID!"); //ErrorCallbackProvider.ReportInfo(string.Format("Current player is: {0}", myId.ID)); GameID myGame = GameID.FromName("mygame"); try { hoard.RegisterGame(myGame, new CKGameItemProvider(myGame)); GameItem[] items = hoard.GetPlayerItems(hoardFixture.UserIDs[0], myGame).Result; ErrorCallbackProvider.ReportInfo("Shutting down HOARD..."); hoard.Shutdown(); } catch (Exception) { Assert.True(false); } }
public void ShortcutCRCCorrect() { GameID gameId = new GameID("\"C:\\Program Files (x86)\\Git\\mingw64\\bin\\wintoast.exe\"", "Git for Windows"); Assert.True(gameId.IsShortcut); Assert.Equal(new GameID(12754778225939316736), gameId); }
static void Main() { Console.CursorVisible = false; GameField matrix = new GameField(); saveStartTime = DateTime.Now; GameID.PrintGameName(); GameField.DrawBorderLines(); for (int i = 0; i < 7; i++) { GameField.EnemyCoordinates(matrix); } while (true) { DrawInitialGameField(matrix); Player.MovePlayer(matrix); Enemy.MoveEnemies(matrix); //Collisions.EatenByEnemy(matrix, Enemy.enemyCoords, CrazyRusher.saveStartTime); if (GameScores.gameOver == true) { break; } } }
public List <Game> GetCategorizedGames(ulong steamId) { var id = new SteamID(steamId); var result = new List <Game>(); var vdf = Path.Combine(Steam.InstallationPath, "userdata", id.AccountID.ToString(), "7", "remote", "sharedconfig.vdf"); var sharedconfig = new KeyValue(); sharedconfig.ReadFileAsText(vdf); var apps = sharedconfig["Software"]["Valve"]["Steam"]["apps"]; foreach (var app in apps.Children) { if (app.Children.Count == 0) { continue; } var appData = new List <string>(); foreach (var tag in app["tags"].Children) { appData.Add(tag.Value); } string gameId = app.Name; if (app.Name.Contains('_')) { // Mods are keyed differently, "<appId>_<modId>" // Ex. 215_2287856061 string[] parts = app.Name.Split('_'); if (uint.TryParse(parts[0], out uint appId) && uint.TryParse(parts[1], out uint modId)) { var gid = new GameID() { AppID = appId, AppType = GameID.GameType.GameMod, ModID = modId }; gameId = gid; } else { // Malformed app id? continue; } } result.Add(new Game() { PluginId = Id, Source = "Steam", GameId = gameId, Categories = new ComparableList <string>(appData), Hidden = app["hidden"].AsInteger() == 1 }); } return(result); }
protected override void ExtractSubRecords(BetterReader reader, GameID gameID, uint size) { var bytes = reader.ReadBytes((int)size); var name = string.Empty; using (var stream = new BetterMemoryReader(bytes)) { var end = stream.Length; while (stream.Position < end) { name = stream.ReadString(4); switch (name) { case "EDID": EDID = new STRSubRecord(); EDID.Deserialize(stream, name); break; case "OBND": OBND = new OBNDSubRecord(); OBND.Deserialize(stream, name); break; case "MODL": MODL = new STRSubRecord(); MODL.Deserialize(stream, name); break; case "MODB": MODB = new BytesSubRecord(); MODB.Deserialize(stream, name); break; case "MODT": MODT = new BytesSubRecord(); MODT.Deserialize(stream, name); break; case "MODS": MODS = new MODSSubRecord(); MODS.Deserialize(stream, name); break; case "MODD": MODD = new MODDSubRecord(); MODD.Deserialize(stream, name); break; default: var rest = stream.ReadUInt16(); stream.ReadBytes(rest); break; } } } }
public override Int32 GetHashCode() { return(GameID.GetHashCode() ^ DataID.GetHashCode() ^ SaveTime.GetHashCode() ^ DataName.GetHashCode() ^ ScoreValue.GetHashCode()); }
/// <inheritdoc /> public override int CompareTo(AStoreGame?other) { return(other switch { null => 1, GOGGame game => GameID.CompareTo(game.GameID), _ => base.CompareTo(other) });
/// <summary> /// Creates new instance of BCGameItemProvider for a particular game using supplied blockchain communication interfase /// </summary> /// <param name="game"></param> /// <param name="comm"></param> public PlasmaGameItemProvider(GameID game, IBCComm comm) { Game = game; plasmaComm = (BC.PlasmaComm)comm; RegisterContractInterfaceID(ERC223GameItemContract.InterfaceID, typeof(ERC223GameItemContract)); RegisterContractInterfaceID(ERC721GameItemContract.InterfaceID, typeof(ERC721GameItemContract)); }
public SimplusInfo(GameID id, Circle circle, ISimplusHP hp, IParty party, ILinkInfoContainer links) { _id = id; _obj2D = circle; _hp = hp; _party = party; _links = links; }
private void StartWorker(GameID gameID) { gameWorker = games.WorkerForGame(gameID, connections, DataProcessor_OnDataProcessed); gameWorker.OnStarting += Worker_OnStarting; gameWorker.OnWorking += Worker_OnWorking; gameWorker.Start(); }
public void SetInfo(ISimplusInfo info) { _id = info.ID; _hp = info.HP; _party = info.Party; _obj2D = info.Obj2D; //? reference _links = info.Links; }
// TODO: implement me public async Task GetUserAchievements(GameID gameId, SteamID steamId) { var response = await RequestUserStats(gameId, steamId); //if (response.Result != EResult.OK || response.AchievementBlocks == null) //return null; //return response.AchievementBlocks; }
public static bool Equals(GameID a, GameID b) { if (a.name == b.name && a.platform == b.platform && a.country == b.country) return true; else return false; }
protected override void ExtractSubRecords(BetterReader reader, GameID gameID, uint size) { base.ExtractSubRecords(reader, gameID, size); /* * var name = string.Empty; * var end = reader.Position + size; * * while (reader.Position < end) * { * name = reader.ReadString(4); * * switch (name) * { * case "EDID": * EDID = new STRSubRecord(); * EDID.Deserialize(reader, name); * break; * * case "FULL": * FULL = new STRSubRecord(); * FULL.Deserialize(reader, name); * break; * * case "WNAM": * WNAM = new STRSubRecord(); * WNAM.Deserialize(reader, name); * break; * * case "SNAM": * SNAM = new STRSubRecord(); * SNAM.Deserialize(reader, name); * break; * * case "DATA": * DATA = new ByteSubRecord(); * DATA.Deserialize(reader, name); * break; * * case "NAM0": * NAM0 = new Vector2iSubRecord(); * NAM0.Deserialize(reader, name); * break; * * case "NAM9": * NAM9 = new Vector2iSubRecord(); * NAM9.Deserialize(reader, name); * break; * * default: * var rest = reader.ReadUInt16(); * reader.ReadBytes(rest); * break; * } * }*/ }
private ModInfo(ModType type, string installFolder) { modType = type; InstallFolder = installFolder; Name = "Unknown Mod"; Links = new ObservableCollection <Link>(); GameId = new GameID(); Developer = "Unknown"; Categories = new ComparableList <string>(); }
public static int Compare(GameID a, GameID b) { int result = compare(a.name,b.name); if (result == 0) result = compare(a.platform,b.platform); if (result == 0) result = compare(a.country,b.country); return result; }
public override void Setup(World world) { world.player.position = Size().TileToWorldCoords().ToVector2() / 2; //world.SpawnNpc(GameID.GetNpcID<Dasher>(), world.player.position + (Vector2.One * 120), Vector2.Zero); world.SpawnNpc(GameID.GetNpcID <Dummy>(), world.player.position + (Vector2.One * 100), Vector2.Zero); for (int i = 0; i < 1; i++) { world.SpawnNpc(GameID.GetNpcID <Seeker>(), world.player.position - (Vector2.One * 100) + (Vector2.One * i * 10), Vector2.Zero); } }
internal static GameAction CreatePlayTask(GameID gameId) { return(new GameAction() { Name = "Play", Type = GameActionType.URL, Path = @"steam://rungameid/" + gameId, IsHandledByPlugin = true }); }
private ModInfo(ModType type, string installFolder) { modType = type; InstallFolder = installFolder; Name = "Unknown Mod"; Links = new List <Link>(); GameId = new GameID(); Developer = "Unknown"; Categories = new List <string>(); }
public bool setGameMonitored(GameID set_me, bool to_me) { if (to_me) { return(addUnique("MonitoredGames", set_me.ToString())); } else { return(this.remove("MonitoredGames", set_me.ToString())); } }
/// <summary> /// Returns GameItem contract for given game and of given type /// </summary> /// <param name="game"></param> /// <param name="contractAddress"></param> /// <param name="contractType"></param> /// <param name="abi">[optional] creates contract with a particular abi</param> /// <returns></returns> public GameItemContract GetGameItemContract(GameID game, string contractAddress, Type contractType, string abi = "") { if (abi == "") { return((GameItemContract)Activator.CreateInstance(contractType, new object[] { game, web, contractAddress })); } else { return((GameItemContract)Activator.CreateInstance(contractType, new object[] { game, web, contractAddress, abi })); } }
/// <inheritdoc/> public async Task <GameID[]> GetHoardGames() { ulong count = await gameCenter.GetGameCount(); GameID[] games = new GameID[count]; for (ulong i = 0; i < count; ++i) { games[i] = await GetGameByIndex(i); } return(games); }
/// <summary> /// Immediately ends the current phase, as stored in GamePhaseSequencer. /// </summary> public void EndCurrentTurnPhase(IPhase nextPhase) { if (nextPhase == null) { Log.LogMsg("[" + GameID.ToString() + "] couldn't determine which phase should come after [" + nextPhase.PhaseName + "|" + nextPhase.PhaseID.ToString() + "]. Game is likely stuck now."); return; } GamePhaseSequencer.ClearSequence(); GamePhaseSequencer.AddItem(nextPhase as Phase, GetTurnPhaseDelay(nextPhase as Phase)); GamePhaseSequencer.ActivateNextItem(); }
public StatsAccessor( SteamClient008 client, SteamPipeHandle pipe, SteamUserHandle user, uint lgameID ) { stats002 = ( SteamUserStats002 )client.GetISteamUserStats( user, pipe, SteamUserStats002.InterfaceVersion ); stats004 = ( SteamUserStats004 )client.GetISteamUserStats( user, pipe, SteamUserStats004.InterfaceVersion ); thisGameID = new GameID( lgameID ); if ( stats002.RequestCurrentStats( thisGameID ) && stats004.RequestCurrentStats() ) { bActive = true; } }
protected override void ExtractSubRecords(BetterReader reader, GameID gameID, uint size) { var bytes = reader.ReadBytes((int)size); var name = string.Empty; using (var stream = new BetterMemoryReader(bytes)) { var end = stream.Length; while (stream.Position < end) { name = stream.ReadString(4); switch (name) { case "EDID": EDID = new STRSubRecord(); EDID.Deserialize(stream, name); break; case "QSTI": var qsti = new FormID(); qsti.Deserialize(stream, name); QSTI.Add(qsti); break; case "QSTR": var qstr = new FormID(); qstr.Deserialize(stream, name); QSTR.Add(qstr); break; case "FULL": FULL = new STRSubRecord(); FULL.Deserialize(stream, name); break; case "PNAM": PNAM = new FloatSubRecord(); PNAM.Deserialize(stream, name); break; case "DATA": DATA = new DIAL_DATASubRecord(); DATA.Deserialize(stream, name); break; default: break; } } } }
private void btnBrowse_Click(object sender, EventArgs e) { FolderBrowserDialog f = new FolderBrowserDialog(); f.ShowNewFolderButton = false; f.Description = "Path to game installation"; f.SelectedPath = Properties.Settings.Default.T7GPath; DialogResult res = f.ShowDialog(this); if (res == DialogResult.OK) { if (!f.SelectedPath.EndsWith("\\")) f.SelectedPath = f.SelectedPath + "\\"; Properties.Settings.Default.T7GPath = f.SelectedPath; Properties.Settings.Default.Save(); path = f.SelectedPath; game = Detector.detectGame(path); readGameData(); } }
public void TrackAppUsageEvent(GameID gameID, int appUsageEvent, string extraInfo = "") { CheckIfUsable(); NativeMethods.User_TrackAppUsageEvent(gameID.AsUInt64, appUsageEvent, extraInfo); }
private void frmMain_Load(object sender, EventArgs e) { // "Fix" T7G path if (!Properties.Settings.Default.T7GPath.EndsWith("\\")) { Properties.Settings.Default.T7GPath = Properties.Settings.Default.T7GPath + "\\"; Properties.Settings.Default.Save(); } game = Detector.detectGame(path); readGameData(); s = new SdlDotNet.Graphics.Surface(this.surface.Width, this.surface.Height); SdlDotNet.Core.Events.Tick += new EventHandler<SdlDotNet.Core.TickEventArgs>(this.Tick); SdlDotNet.Core.Events.TargetFps = 15; Thread thread = new Thread(new ThreadStart(SdlDotNet.Core.Events.Run)); thread.IsBackground = true; thread.Name = "SDL.NET"; thread.Priority = ThreadPriority.Normal; /* GJD.RLData rl; rl.length = (uint)(new System.IO.FileInfo("tmp.vdx")).Length; rl.filename = "tmp.vdx"; rl.offset = 0; rl.number = 0; vdx = new VDX(new System.IO.BinaryReader(System.IO.File.Open("tmp.vdx", System.IO.FileMode.Open)), rl, s); */ thread.Start(); }
public bool isGameMonitored(GameID check_me) { return get("MonitoredGames").Contains(check_me.ToString()); }
public static String ToString(GameID id) { StringBuilder return_me = new StringBuilder(id.name); if (id.platform != GamePlatform.Multiple) { return_me.Append("«" + id.platform.ToString()); } if (id.country != null) { return_me.Append("«" + id.country); } return return_me.ToString(); }
public bool setGameMonitored(GameID set_me, bool to_me) { if (to_me) { return addUnique("MonitoredGames", set_me.ToString()); } else { return this.remove("MonitoredGames", set_me.ToString()); } }
public async Task<ActionResult> AddGameAccount(GameID GameId, string returnUrl) { if (GameId != GGCharityData.GameID.StarCraft) { return new HttpStatusCodeResult(HttpStatusCode.NotImplemented); } return await Data.PerformAsync<ActionResult>(async () => { var currentUser = await GetCurrentUserAsync(); if (currentUser.HasGame(GameId)) { return Redirect(returnUrl); } var gameList = await Data.GetGameManager().GetGameListAsync(); var game = gameList.SingleOrDefault(g => g.GameId == GameId); ViewBag.ReturnUrl = returnUrl; ViewBag.GameName = game.Name; ViewBag.GameId = GameId; ViewBag.ReturnUrl = returnUrl; return View("AddGameAccount"); }); }