Ejemplo n.º 1
0
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    boolean doyouwanaPlay = true;
    while (doyouwanaPlay) {
      System.out.println(
          "Welcome to tic tac toe.\nLets play the game.\n"
              + "Enter the character you wanna choose for yourself");
      char userToken = sc.nextLine().charAt(0);
      System.out.println("\nEnter the character you wanna choose for your opponent\n");
      char aitoken = sc.nextLine().charAt(0);
      TicTactoe game = new TicTactoe(userToken, aitoken);

      Ai ai = new Ai();

      System.out.println();
      System.out.println("Lets start a game");
      game.printBoardIndex();
      System.out.println();
      game.printBoard();
      game.currentmarker = game.usermarker;
      while (game.IsgameOver().equals("Not over")) {
        if (game.currentmarker == game.usermarker) {

          System.out.println("Enter location you want to fill");
          int spot = sc.nextInt();
          while (!game.playTurn(spot)) {
            System.out.println("Try again , soot already taken");
            spot = sc.nextInt();
          }

          System.out.println("You picked" + spot + "place");

        } else {

          System.out.println("Its my turn");
          int aispot = ai.pickSpot(game);
          game.playTurn(aispot);
          System.out.println("I picked" + aispot + "place");
        }
        System.out.println();
        game.printBoard();
      }
      System.out.println("Game is over");
      System.out.println(game.IsgameOver());

      System.out.println(
          "Do you wanna play again?\n Type y if yes else type anything if you bored");
      char wannaplay = sc.next().charAt(0);
      doyouwanaPlay = (wannaplay == 'y');
    }
  }
Ejemplo n.º 2
0
  private void applyLootList(List<String> allowedItems, List<String> allowedWeapons, Ai ai) {
    ai.setWeapon(
        Weapon.stringToWeapon(allowedWeapons.get(new Random().nextInt(allowedWeapons.size()))));

    int randomItemCount = new Random().nextInt(5);
    if (allowedItems.size() > 0) {

      boolean hasArmour = false;

      for (int i = 0; i < randomItemCount; i++) {
        String item = allowedItems.get(new Random().nextInt(allowedItems.size()));

        if (item != null
            && (!(item.equals(ArmourPlates1.NAME) || item.equals(ArmourPlates2.NAME)) || !hasArmour)
            && (!ai.getInventory().hasItem(Item.stringToItem(item)))) {
          ai.addItem(Item.stringToItem(item));

          if (item.equals(ArmourPlates1.NAME) || item.equals(ArmourPlates2.NAME)) hasArmour = true;
        }
      }
    }
  }
Ejemplo n.º 3
0
  private void generatePlayerTeam(ArrayList<Squaddie> squad, LevelBlock levelBlock) {
    double[] randomLocation = levelManager.randomInPosition(levelBlock);

    for (int i = 0; i < squad.size(); i++) {

      Ai ai = null;
      AiImage aiImg = null;

      if (squad.get(i).isVehicle()) {
        aiImg =
            new VehicleImage(
                aiCrowd,
                combatMembersManager,
                combatUiManager,
                combatVisualManager,
                panningManager,
                100,
                100,
                mouseAbilityHandler,
                floatingIcons);

        switch (squad.get(i).getVehicleType()) {
          case MuleAi.MULE:
            ai =
                new MuleAi(
                    panningManager,
                    floatingIcons,
                    mouseAbilityHandler,
                    squad.get(i).getName(),
                    randomLocation[0],
                    randomLocation[1],
                    combatInorganicManager,
                    levelManager,
                    lootbox,
                    combatMembersManager,
                    combatUiManager,
                    combatVisualManager,
                    aiCrowd,
                    turnProcess);
            break;
        }

        ai.setImage(squad.get(i).getImage());
        ai.setTeam("1Player");
      } else {
        aiImg =
            new AiImage(
                aiCrowd,
                combatMembersManager,
                combatUiManager,
                combatVisualManager,
                panningManager,
                100,
                100,
                mouseAbilityHandler,
                floatingIcons);

        ai =
            new Ai(
                floatingIcons,
                mouseAbilityHandler,
                squad.get(i).getName(),
                randomLocation[0],
                randomLocation[1],
                combatInorganicManager,
                levelManager,
                lootbox,
                combatMembersManager,
                combatUiManager,
                combatVisualManager,
                aiCrowd,
                panningManager,
                turnProcess);
        ai.setImage(squad.get(i).getImage());
        ai.setTeam("1Player");
      }

      Iterator<String> skillIt = squad.get(i).getSkills();
      while (skillIt.hasNext()) {
        String next = skillIt.next();
        ai.setSkill(next, squad.get(i).getSkillLevel(next));
      }

      ai.setWeapon(Weapon.stringToWeapon(squad.get(i).getWeapon()));

      Iterator<String> itemIt = squad.get(i).getItems();

      while (itemIt.hasNext()) {
        ai.addItem(Item.stringToItem(itemIt.next()));
      }

      ai.assignAbilities();
      aiImg.setAi(ai);
      aiCrowd.addDisplayItem(aiImg);
      aiCrowd.addMouseActionItem(aiImg);

      aiCrowd.addActor(ai, new DirectorClassification(DirectorArchetype.PLAYER));
      aiCrowd.addMask(aiImg);

      randomLocation = levelManager.randomInPosition(levelBlock);

      combatMembersManager.addAi(ai);
    }
  }
Ejemplo n.º 4
0
 @Override
 public boolean isTargetHostile(Ai target) {
   return !target.isDead() && target != this;
 }