public int StartGame() { string jsonGetData = string.Empty; int responseCode; AzureTable NewTable = new AzureTable("BossHuntv1"); responseCode = JTAzureTableRESTCommands.GetAllTables(storageName, sAS, "('" + NewTable.TableName + "')", out jsonGetData); if (responseCode == 7) { responseCode = JTAzureTableRESTCommands.CreateTable("POST", storageName, sAS, "Tables", JsonConvert.SerializeObject(NewTable), string.Empty, string.Empty); responseCode = JTAzureTableRESTCommands.GetAllTables(storageName, sAS, "('" + NewTable.TableName + "')", out jsonGetData); } if (responseCode == 200) { // If the Boss Hunt Table is successfully created or it exists, then check to see if there is an existing user and load, otherwise create the user IEntity defaultUser = new Hero(); // Create a Blank User //Entity blankUser = defaultUser.CreateBlankEntity(); // Create a Blank User defaultUser.CreateBlankEntity(); // Create a Blank User responseCode = JTAzureTableRESTCommands.GetAllEntities(storageName, sAS, NewTable.TableName + "(PartitionKey='" + defaultUser.GetEntityStat(EntityStat.PartitionKey) + "',RowKey='" + defaultUser.GetEntityStat(EntityStat.RowKey) + "')", out jsonGetData); string test = JsonConvert.SerializeObject(defaultUser); if (responseCode == 7) { responseCode = JTAzureTableRESTCommands.ChangeEntity("POST", storageName, sAS, NewTable.TableName, JsonConvert.SerializeObject(defaultUser), string.Empty, string.Empty); } else { responseCode = 201; // User Loaded or Created successfully. } // If the User is successfully created or already existed, then check to see if there is an existing boss and load, otherwise create the boss IEntity defaultBoss = new Boss(); // Create a Blank Boss //Entity blankBoss = defaultBoss.CreateBlankEntity(); defaultBoss.CreateBlankEntity(); responseCode = JTAzureTableRESTCommands.GetAllEntities(storageName, sAS, NewTable.TableName + "(PartitionKey='" + defaultBoss.GetEntityStat(EntityStat.PartitionKey) + "',RowKey='" + defaultBoss.GetEntityStat(EntityStat.RowKey) + "')", out jsonGetData); if (responseCode == 7) { responseCode = JTAzureTableRESTCommands.ChangeEntity("POST", storageName, sAS, NewTable.TableName, JsonConvert.SerializeObject(defaultBoss), string.Empty, string.Empty); } else { responseCode = 201; // Boss Loaded or Created successfully. } // ########################################################################### // Create Relic Entries if they doesn't exist if (responseCode == 201) { responseCode = Helper.CreateRelics(NewTable.TableName); } // ########################################################################### } return(responseCode); }
public static int CreateRelics(string table) { int responseCode; string jsonGetData = string.Empty; // ######################################################################################### // Create the Attack Relic BaseRelic AtkRelic = new AttackRelic(); responseCode = JTAzureTableRESTCommands.GetAllEntities(storageName, sAS, table + "(PartitionKey='" + AtkRelic.PartitionKey + "',RowKey='" + AtkRelic.RowKey + "')", out jsonGetData); if (responseCode == 7) { responseCode = JTAzureTableRESTCommands.ChangeEntity("POST", storageName, sAS, table, JsonConvert.SerializeObject(AtkRelic), string.Empty, string.Empty); } else { responseCode = 201; } // ######################################################################################### // ######################################################################################### // Create the Health Relic BaseRelic HPRelic = new HealthRelic(); responseCode = JTAzureTableRESTCommands.GetAllEntities(storageName, sAS, table + "(PartitionKey='" + HPRelic.PartitionKey + "',RowKey='" + HPRelic.RowKey + "')", out jsonGetData); if (responseCode == 7) { responseCode = JTAzureTableRESTCommands.ChangeEntity("POST", storageName, sAS, table, JsonConvert.SerializeObject(HPRelic), string.Empty, string.Empty); } else { responseCode = 201; } // ######################################################################################### // ######################################################################################### // Create the Speed Relic BaseRelic SPRelic = new SpeedRelic(); responseCode = JTAzureTableRESTCommands.GetAllEntities(storageName, sAS, table + "(PartitionKey='" + SPRelic.PartitionKey + "',RowKey='" + SPRelic.RowKey + "')", out jsonGetData); if (responseCode == 7) { responseCode = JTAzureTableRESTCommands.ChangeEntity("POST", storageName, sAS, table, JsonConvert.SerializeObject(SPRelic), string.Empty, string.Empty); } else { responseCode = 201; } // ######################################################################################### // ######################################################################################### // Create the Accuracy Relic BaseRelic AccRelic = new AccuracyRelic(); responseCode = JTAzureTableRESTCommands.GetAllEntities(storageName, sAS, table + "(PartitionKey='" + AccRelic.PartitionKey + "',RowKey='" + AccRelic.RowKey + "')", out jsonGetData); if (responseCode == 7) { responseCode = JTAzureTableRESTCommands.ChangeEntity("POST", storageName, sAS, table, JsonConvert.SerializeObject(AccRelic), string.Empty, string.Empty); } else { responseCode = 201; } // ######################################################################################### return(responseCode); }