public override void MakeMove(GameApi api) { IEnumerable <CountryApi> countries = api.Countries; CountryApi myCountry = api.Country; foreach (CountryApi c in countries) { myCountry.TryDeclareWar(this, c); } IEnumerable <ArmyApi> armies = api.Country.Armies; foreach (ArmyApi a in armies) { if (a.MovingDirection == Direction.None) { if (a.IsArmyMovePossible(this, Direction.East)) { a.TrySendArmy(this, Direction.East); } else if (a.IsArmyMovePossible(this, Direction.North)) { a.TrySendArmy(this, Direction.North); } else if (a.IsArmyMovePossible(this, Direction.West)) { a.TrySendArmy(this, Direction.West); } else if (a.IsArmyMovePossible(this, Direction.South)) { a.TrySendArmy(this, Direction.South); } } } }
public static void PlayGame(GameApi gameApi, string userResponse) { Console.WriteLine(gameApi.ProcessCommand(userResponse)); string newResponse = Console.ReadLine(); PlayGame(gameApi, newResponse); }
static void Main() { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Welcome To"); Console.WriteLine("____ ____.__ __ .__ __________.__ .___ ________ __ "); Console.WriteLine("\\ \\ / /|__| | _|__| ____ ____ \\______ \\ | ____ ____ __| _/ \\_____ \\ __ __ ____ _______/ |_ "); Console.WriteLine(" \\ Y / | | |/ / |/ \\ / ___\\ | | _/ | / _ \\ / _ \\ / __ | / / \\ \\| | \\_/ __ \\ / ___/\\ __\\"); Console.WriteLine(" \\ / | | <| | | \\/ /_/ > | | \\ |_( <_> | <_> ) /_/ | / \\_/. \\ | /\\ ___/ \\___ \\ | | "); Console.WriteLine(" \\___/ |__|__|_ \\__|___| /\\___ / |______ /____/\\____/ \\____/\\____ | \\_____\\ \\_/____/ \\___ >____ > |__| "); Console.WriteLine(" \\/ \\//_____/ \\/ \\/ \\__> \\/ \\/ "); Console.ResetColor(); Console.ForegroundColor = ConsoleColor.Gray; Console.WriteLine(" ___"); Console.WriteLine(" ( (("); Console.WriteLine(" ) ))"); Console.WriteLine(" .::. / /("); Console.WriteLine(" \'M .-;-.-.-.-.-.-.-.-.-/| ((::::::::::::::::::::::::::::::::::::::::::::::.._"); Console.WriteLine("(J ( ( ( ( ( ( ( ( ( ( ( | )) -====================================- _.>"); Console.WriteLine(" `P `-;-`-`-`-`-`-`-`-`-\\| ((::::::::::::::::::::::::::::::::::::::::::::::\'\'"); Console.WriteLine(" `::\' \\ \\("); Console.WriteLine(" ) ))"); Console.WriteLine(" (_(("); Console.WriteLine(GameApi.StartGame()); while (GameRunning) { var commandProcessed = GameApi.ProcessCommand(Console.ReadLine()); Console.WriteLine(commandProcessed.Item1); GameRunning = commandProcessed.Item2; } Console.ReadLine(); }
public Assessments(string jsonPath, GameApi gameApi) { JsonPath = jsonPath; GameApi = gameApi; Classes = new(this); Members = new(this); }
void Awake() { Debug.Log(gameCodeName); if (Volume == false) VolumeOff(); if (Volume == true) VolumeOn(); gameapi = gameObject.GetComponent<GameApi>(); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, [Queue("fleeteventranks"), StorageAccount("sttfleetg5618_STORAGE")] ICollector <string> msg, ExecutionContext context, ILogger log) { log.LogInformation("Fleet event ranks started"); var configuration = new Configuration(context.FunctionAppDirectory); var gameApi = new GameApi(configuration.STTApiConfiguration); await gameApi.Login(); var data = await gameApi.GetFleetMemberInfo(); var userdailies = UserDailies.Load(data); var squadranks = SquadEventRank.Load(data); log.LogInformation("Fleet event ranks users: " + userdailies.Count); var queueItem = new EventRankQueueItem() { UserDailies = userdailies, SquadEventRanks = squadranks }; msg.Add(JsonConvert.SerializeObject(queueItem)); return(new OkResult()); }
static void Main(string[] args) { var repo = new InMemoryRepository <Game>(); var logger = new NLogLogger("ConsoleGameRunner"); // TODO: move to IOC Container if this gets more complicated var gameApi = new GameApi(new SimpleGameFactory(), repo, new PublicGameAuthorizer(repo), logger); Console.WriteLine("Welcome to Battleship"); logger.Info("Welcome to Battleship"); var player1Name = args.Length == 2 ? args[0] : "Player 1"; var player2Name = args.Length == 2 ? args[1] : "Player 2"; var gameId = gameApi.Create(player1Name, player2Name, GameCreatorUserId); CaptureShipLocation(gameApi, gameId, player1Name); CaptureShipLocation(gameApi, gameId, player2Name); var game = gameApi.Read(gameId, GameCreatorUserId); while (game.Status != GameStatus.Completed) { Console.WriteLine(); Console.WriteLine(GameDisplayer.Display(game)); Console.WriteLine(); CaptureAttack(gameApi, gameId); } Console.WriteLine(); Console.WriteLine(GameDisplayer.Display(game)); Console.ReadLine(); }
private static void CaptureAttack(GameApi gameApi, Guid gameId) { var game = gameApi.Read(gameId, GameCreatorUserId); var playerNumber = game.CurrentTurnPlayer; var playerName = playerNumber == 1 ? game.Player1 : game.Player2; var attackProceededWithoutException = false; while (!attackProceededWithoutException) { Console.WriteLine($"{playerName}: Enter a location to attack (e.g. 'D4')"); var attackLocation = Console.ReadLine(); try { gameApi.Attack(gameId, playerName, new Location(attackLocation)); attackProceededWithoutException = true; } catch (FormatException) { Console.WriteLine($"'{attackLocation}' is not in the expected format"); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine($"A serious error occurred: {ex.Message}"); } } }
private static void CaptureShipLocation(GameApi gameApi, Guid gameId, string playerName) { var game = gameApi.Read(gameId, GameCreatorUserId); var playerIndex = playerName == game.Player1 ? 0 : 1; while (game.Ships[playerIndex].Status != ShipStatus.Active) { Console.WriteLine($"{playerName}: Enter your ship location (e.g. 'A3 A5')"); var shipLocation = Console.ReadLine(); var shipLocationTokens = shipLocation.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries); try { gameApi.PlaceShip(gameId, playerName, new Location(shipLocationTokens[0]), new Location(shipLocationTokens[1])); game = gameApi.Read(gameId, GameCreatorUserId); } catch (FormatException) { Console.WriteLine($"'{shipLocation}' is not in the expected format"); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } catch (Exception ex) { Console.WriteLine($"A serious error occurred: {ex.Message}"); } } }
private static void TestConsumer(GameApi api, PlayersApi players, Configuration config) { GameRules rules = new GameRules(true, 2, "Test", 1, password: null); PrintHeader("Create Game"); int game = api.CreateGame(rules); Print("Game ID: " + game); Print("Stats : " + api.GetGameState(game)); PrintHeader("Join Game"); players.Join(game); ConsumerApi consumerApi = new ConsumerApi(config); JoinResponse response = consumerApi.RegisterConsumer(game, new ConsumerRegistration("Test", "Ein consumer")); Print($"id : {response.Id}"); Print($"pat : {response.Pat}"); players.Configuration.ApiKey["pat"] = response.Pat; api.Configuration.ApiKey["pat"] = response.Pat; config.ApiKey["pat"] = response.Pat; JoinResponse somePlayer = players.Join(game); Print(players.GetPlayer(game, somePlayer.Id).ToJson()); PrintHeader("Start Game"); api.CommitAction(game, ActionType.STARTGAME); PrintHeader("Fetch Events"); EventHandlingApi eventApi = new EventHandlingApi(config); for (int i = 0; i < 8; i++) { Print(eventApi.FetchNextEvent(game).Type.ToString()); } }
public void SetUp() { dbContext = DbContextUtility.CreateMockDb(); var logger = Substitute.For <ILogger <GameApi> >(); var cdnService = Substitute.For <ICdnService>(); testObj = new GameApi(logger, dbContext, cdnService); }
/// <summary> /// Initializes a new instance of the <see cref="toolControl"/> class. /// </summary> public toolControl() { var url = "http://localhost/BlackJackApi/"; this.InitializeComponent(); //initialize connection _lobbyClient = new LobbyApi(url); _gameClient = new GameApi(url); }
public override void Load() { Bind <IProgram>().To <Program>(); Bind <IScreen>().To <Screen>().InSingletonScope(); Bind <IStateMachine>().To <StateMachine>().InSingletonScope(); Bind <ILobby>().To <Lobby>(); Bind <IGame>().To <Game>(); var gameApi = new GameApi("http://www.glueware.nl/Klootzakken/kzapi"); Bind <GameApi>().ToConstant(gameApi); }
void Awake() { if (_api == null) { _api = FindObjectOfType <GameApi>(); } if (_api == null) { Debug.LogError("'Api' field must be set!"); } }
static void Main(string[] args) { Configuration c = new Configuration { BasePath = "http://localhost:5050/v1" }; GameApi api = new GameApi(c); PlayersApi players = new PlayersApi(c); PrintHeader("{Test Game Lifecycle}"); TestStartGame(api, players, c); return; PrintHeader("\n{Test Consumers}"); TestConsumer(api, players, c); }
static void Main(string[] args) { GameApi gameApi = new GameApi(); while (gameApi.GetGameId().Equals("")) { Console.WriteLine("Would you like to Load a Game or Start a new Game?(Load / New Slot Number(1, 2, 3, 4))"); Console.WriteLine(gameApi.Command(Console.ReadLine())); while (gameApi.GetGameId() != "") { Console.WriteLine("What would you like to do?"); Console.WriteLine(gameApi.Command(Console.ReadLine())); } } }
static void Main(string[] args) { GameApi gameApi = new GameApi(); Console.WriteLine("Welcome to the Castle Grimtol Text Adventure Game!"); Console.WriteLine("Would you like to play a game? (Yes No or Tutorial)"); var userResponse = Console.ReadLine(); Console.WriteLine(gameApi.StartGame(userResponse)); var newResponse = Console.ReadLine(); PlayGame(gameApi, newResponse); Console.WriteLine(gameApi.GetGameHistory()); Console.ReadLine(); }
protected void InitWithGame(Game game) { _game = game; _id = new Guid(); _factory = Substitute.For <IGameFactory>(); _factory.Create(Arg.Any <string>(), Arg.Any <string>()).Returns(_game); _repo = Substitute.For <IRepository <Game> >(); _repo.Add(Arg.Any <Game>()).Returns(_id); _repo.Get(Arg.Any <Guid>()).Returns(_game); _authorizer = Substitute.For <IAuthorizer>(); _logger = Substitute.For <ILogger>(); _sut = new GameApi(_factory, _repo, _authorizer, _logger); }
static void nMain(string[] args) { var url = "http://localhost/BlackJackApi/"; lobbyClient = new LobbyApi(url); var games = lobbyClient.ApiLobbyListGet(); var gameId = lobbyClient.ApiLobbyNewgameNameMinbetMaxbetPost("HelloTomx", 10, 100).Replace("\"", ""); gameClient = new GameApi(url); Player1 = gameClient.GameIdJoinPut(gameId, "John Snow", Position1); Player2 = gameClient.GameIdJoinPut(gameId, "Stephen Fry", Position2); PlayRound(gameId); return; }
static void cameraFix() { GameApi game = new GameApi(); BotApi bot = new BotApi(); string img = Directory.GetCurrentDirectory() + @"\Images\Game\unfixedcamera.png"; if (File.Exists(img)) { game.camera.toggleIfUnlocked(); } else { bot.log("cameraFix error: Image not found."); } }
public static object fetchGameDetail(string gameId) { return(new ThunkAction <AppState>((dispatcher, getState) => { return GameApi.FetchGameDetail(gameId: gameId) .Then(gameDetailResponse => { dispatcher.dispatch(new RankListAction { rankList = new List <RankData> { gameDetailResponse } }); dispatcher.dispatch(new FetchGameDetailSuccessAction()); }) .Catch(error => { dispatcher.dispatch(new FetchGameDetailFailureAction()); Debuger.LogError(message: error); }); })); }
private static double?PlayRound(string gameId, GameApi gameClient, int position, PlayerAccount player, int bet) { return(0); //gameClient.GameIdPlayerPlayerIdBetAmountPost(gameId, player.Id, bet); //gameClient.GameIdPlayerPlayerIdStandPost(gameId, player.Id); //result = gameClient.GameIdDetailsGet(gameId); //outcome = result.RoundInProgressSettlements.FirstOrDefault(s => s.PlayerPosition == position); //if (outcome == null) //{ // Console.WriteLine("oops"); //} //else //{ // Console.WriteLine("outcome : " + outcome.WagerOutcome); //} //return result.Players.First(p => p.Id == player.Id).Account.Balance; }
private static void TestStartGame(GameApi api, PlayersApi players, Configuration config) { GameRules rules = new GameRules(true, 2, "Test", 1, password: null); PrintHeader("Create Game"); int game = api.CreateGame(rules); Print("Game ID: " + game); Print("Stats : " + api.GetGameState(game)); PrintHeader("Join Game"); JoinResponse response = players.Join(game); Print($"id : {response.Id}"); Print($"pat : {response.Pat}"); players.Configuration.ApiKey["pat"] = response.Pat; api.Configuration.ApiKey["pat"] = response.Pat; config.ApiKey["pat"] = response.Pat; players.Join(game); Print(players.GetPlayer(game, response.Id).ToJson()); PrintHeader("Start Game"); api.CommitAction(game, ActionType.STARTGAME); PrintHeader("Fetch Events"); EventHandlingApi eventApi = new EventHandlingApi(config); bool run = true; int c = 1; try { while (run) { EventType type = eventApi.TraceEvent(game, wait: true, batch: false)[0]; run = type != EventType.Gameendevent; GenericEvent ev = eventApi.FetchNextEvent(game); Print(c++ + ". Event: " + type); Print(ev.ToJson() + "\n"); } } catch (Exception) { Console.Out.WriteLine("TraceEvent(" + game + ")"); throw; } }
static void Main(string[] args) { Console.SetWindowSize(Console.LargestWindowWidth, Console.LargestWindowHeight); var api = new GameApi(); IGameState gameState; Console.WriteLine("Welcome Brave soul what is your name? "); var playerName = Console.ReadLine(); gameState = api.TryLoadGame(playerName); string welcomeMessage = gameState.IsRestoredGame ? $"Welcome back {playerName}" : $"Welcome new adventurer I will record your history as the tale of {playerName}"; Console.WriteLine(welcomeMessage); while (gameState.Active) { PrintGameState(gameState); gameState = api.ProcessInput(Console.ReadLine(), gameState); } }
public static object fetchGames(int page) { return(new ThunkAction <AppState>((dispatcher, getState) => { return GameApi.FetchGames(page: page) .Then(gamesResponse => { dispatcher.dispatch(new RankListAction { rankList = gamesResponse.rankList }); var gameIds = new List <string>(); gamesResponse.rankList.ForEach(rankData => { gameIds.Add(item: rankData.id); }); dispatcher.dispatch(new FetchGameSuccessAction { gameIds = gameIds, hasMore = gamesResponse.hasMore, pageNumber = gamesResponse.currentPage }); }) .Catch(error => { dispatcher.dispatch(new FetchGameFailureAction()); Debuger.LogError(message: error); }); })); }
public static async Task <IActionResult> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req, ExecutionContext context, ILogger log) { log.LogInformation("Fleet dailies started"); var configuration = new Configuration(context.FunctionAppDirectory); var gameApi = new GameApi(configuration.STTApiConfiguration); await gameApi.Login(); var data = await gameApi.GetFleetMemberInfo(); var fleet = UserDailies.Load(data); log.LogInformation("Fleet dailies users: " + fleet.Count); StringBuilder message = new StringBuilder(); message.AppendLine($"Dailies (UTC) {DateTime.UtcNow.ToString("dd.MM.yyyy HH:mm")}"); var grouped = fleet.GroupBy(d => d.Squadron); foreach (var group in grouped) { var squadName = Regex.Replace(group?.Key ?? string.Empty, @"\<\#[^<>]*\>", string.Empty); message.AppendLine($"__{squadName}__"); foreach (var member in group) { message.AppendLine($"{member.Name}: **{member.Dailies}**"); } message.AppendLine(string.Empty); } HttpClient client = new HttpClient(); var d1 = JsonConvert.SerializeObject(new { content = message.ToString() }); var result = await client.PostAsync(configuration.DiscordConfiguration.DiscordDailiesWebhookUrl, new StringContent(d1, Encoding.UTF8, "application/json")); result.EnsureSuccessStatusCode(); return(new OkResult()); }
public static void Main(string[] args) { GameApi game = new GameApi(); Console.WriteLine(""); Console.WriteLine("Welcome to Calorie Castle!"); Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(game.processCommand("H")); game.startGame(); string PlayerChoice; bool playing = true; while (playing) { Console.WriteLine(""); Console.ForegroundColor = ConsoleColor.Yellow; Console.WriteLine("What would you like to do next? (Note: You can not use food items you have not taken.)"); Console.ResetColor(); PlayerChoice = Console.ReadLine(); if (PlayerChoice == "H") { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine(game.processCommand(PlayerChoice)); } else { Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(game.processCommand(PlayerChoice)); } } }
public Game MapApiGame(GameApi gameApi) { return(m_mapper.Map <GameApi, Game>(gameApi)); }
public abstract void MakeMove(GameApi api);
void Awake() { gameapi = gameObject.GetComponent<GameApi>(); }
public void ExitGame() { GameApi.Navigate_Levelboard(); }
public void ResumeGame() { GameApi.Gameplay_Resume(); }