Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Erfan #213

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Erfan #213

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added core/assets/Card/Spell/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/10.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/11.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/12.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/13.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/14.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/15.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/16.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/17.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/18.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/19.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/20.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/21.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/Card/Spell/9.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion core/assets/Files/Data/Accounts.json

Large diffs are not rendered by default.

Binary file added core/assets/button/button_confirm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/button/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/button/decreaseButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/button/increaseButton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added core/assets/button/secondCustom1-1.png
Binary file added core/assets/button/secondCustom1.png
Binary file modified core/assets/button/yellow glow.png
Binary file added core/assets/sfx/end game.mp3
Binary file not shown.
6 changes: 6 additions & 0 deletions core/src/graphic/main/AssetHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,12 @@ public static synchronized void load() {
assetManager.load("button/card in deck.png", Texture.class);
assetManager.load("button/card in deck1.png", Texture.class);
assetManager.load("button/deckName.png", Texture.class);
assetManager.load("button/secondCustom1.png", Texture.class);
assetManager.load("button/secondCustom1-1.png", Texture.class);
assetManager.load("button/increaseButton.png", Texture.class);
assetManager.load("button/decreaseButton.png", Texture.class);
assetManager.load("button/multiplayer1.png", Texture.class);
assetManager.load("button/multiplayer1-1.png", Texture.class);


for(int i = 1; i <= 11; i++)
Expand Down
196 changes: 119 additions & 77 deletions core/src/graphic/screen/BattleScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
import model.game.CellEffect;
import model.game.Game;
import model.game.Player;
import network.Client;
import network.MouseState;

import java.awt.*;
import java.util.ArrayList;
Expand Down Expand Up @@ -149,7 +151,6 @@ public void create() {
manaStart2 = new Vector2(1330 - mana.getWidth(), 730);

mousePos = new Vector2();

hero1Icon = AssetHandler.getData().get(player1.getHero().getIconId());
hero2Icon = AssetHandler.getData().get(player2.getHero().getIconId());

Expand Down Expand Up @@ -283,87 +284,13 @@ public boolean keyTyped(char character) {

@Override
public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if(game.isGameEnded()){
ScreenManager.setScreen(new MenuScreen());
}
if(endTurnButton.isActive()){
endTurn();
} else if(endGameButton.isActive()){
game.exitFromGame();
endGame();
} else if(graveyardButton.isActive()){
showingGraveyard = !showingGraveyard;
} else if(fastForwardButton.isActive()){
setFastForward();
}
else if(checkHeroSp()){
if(game.getWhoIsHisTurn().canUseHeroSp())
heroSpSelected = true;
} else if(getMouseCell() != null){
if(getMouseCell().getInsideArmy() != null && game.getWhoIsHisTurn().isFriend(getMouseCell().getInsideArmy())) {
selectedCell = getMouseCell();
selectedCellHand = null;
heroSpSelected = false;
selectedArmy = selectedCell.getInsideArmy();
setCommand("select " + selectedArmy.getID().getValue());
synchronized (game){
game.notify();
}
} else if(selectedArmy != null && getMouseCell().getInsideArmy() == null) {
Cell cell = getMouseCell();
if (!game.getWhoIsHisTurn().canMove(selectedCell, cell)){
setPopUp("Invalid Cell");
return false;
}
runSound.play();
game.getWhoIsHisTurn().moveArmy(selectedCell, cell);
selectedCell = null;
selectedArmy = null;
} else if(selectedCellHand != null && getMouseCell().getInsideArmy() == null) {
// Cell cell = getMouseCell();
// if(game.getWhoIsHisTurn().moveFromHandToCell(handCards.get(selectedCellHand), cell));
// handCards.put(selectedCellHand, null);
// selectedCellHand = null;
} else if(selectedArmy != null && getMouseCell().getInsideArmy() != null) {
Cell cell = getMouseCell();
Army target = cell.getInsideArmy();
if(game.getWhoIsHisTurn().isInRange(selectedCell, cell)) {
attackSound.play();
animations.get(selectedArmy).attack();
if (game.getWhoIsHisTurn().isInRange(cell, selectedCell))
animations.get(target).attack();
}
game.getWhoIsHisTurn().attack(selectedCell, cell);
if(selectedCell.getInsideArmy().getHp() <= 0){
animations.get(selectedArmy).death();
game.setupCardDeaf(selectedCell);
}
if(cell.getInsideArmy().getHp() <= 0){
animations.get(target).death();
game.setupCardDeaf(cell);
}
selectedCell = null;
selectedArmy = null;
} else if(heroSpSelected){
game.getWhoIsHisTurn().useSpecialPower(getMouseCell());
}
} else if(getMouseHandCell() != null){
selectedCellHand = getMouseHandCell();
selectedCell = null;
selectedArmy = null;
heroSpSelected = false;
}
mouseTouchDown();
return false;
}

@Override
public boolean touchUp(int screenX, int screenY, int pointer, int button) {
if(selectedCellHand != null && getMouseCell()!= null && getMouseCell().getInsideArmy() == null){
Cell cell = getMouseCell();
if(game.getWhoIsHisTurn().moveFromHandToCell(handCards.get(selectedCellHand), cell));
handCards.put(selectedCellHand, null);
selectedCellHand = null;
}
mouseTouchUp();
return false;
}

Expand All @@ -383,7 +310,122 @@ public boolean scrolled(int amount) {
}
});
}
public void updateByServer() {
camera.update();
shapeRenderer.setProjectionMatrix(camera.combined);
game = Game.getCurrentGame();
player1 = game.getFirstPlayer();
player2 = game.getSecondPlayer();

if(game.isGameEnded()){
endGame();
}

checkTurnTime();

updateHandCells();

setAnimations();
Client.setMousePos();
mousePos.set(Client.getMousePos());
//mousePos.set(Gdx.input.getX(), Gdx.input.getY());
mousePos = viewport.unproject(mousePos);

endTurnButton.setActive(endTurnButton.contains(mousePos));
endGameButton.setActive(endGameButton.contains(mousePos));
graveyardButton.setActive(graveyardButton.contains(mousePos));
fastForwardButton.setActive(fastForwardButton.contains(mousePos));

updateGraveyard();
if(Client.getMouseState() == MouseState.TOUCH_DOWN) {
mouseTouchDown();
}
else if(Client.getMouseState() == MouseState.TOUCH_UP) {
mouseTouchUp();
}
}
public void mouseTouchUp() {
if(selectedCellHand != null && getMouseCell()!= null && getMouseCell().getInsideArmy() == null){
Cell cell = getMouseCell();
if(game.getWhoIsHisTurn().moveFromHandToCell(handCards.get(selectedCellHand), cell));
handCards.put(selectedCellHand, null);
selectedCellHand = null;
}
return;

}
public void mouseTouchDown() {
if (game.isGameEnded()) {
ScreenManager.setScreen(new MenuScreen());
}
if (endTurnButton.isActive()) {
endTurn();
} else if (endGameButton.isActive()) {
game.exitFromGame();
endGame();
} else if (graveyardButton.isActive()) {
showingGraveyard = !showingGraveyard;
} else if (fastForwardButton.isActive()) {
setFastForward();
} else if (checkHeroSp()) {
if (game.getWhoIsHisTurn().canUseHeroSp())
heroSpSelected = true;
} else if (getMouseCell() != null) {
if (getMouseCell().getInsideArmy() != null && game.getWhoIsHisTurn().isFriend(getMouseCell().getInsideArmy())) {
selectedCell = getMouseCell();
selectedCellHand = null;
heroSpSelected = false;
selectedArmy = selectedCell.getInsideArmy();
setCommand("select " + selectedArmy.getID().getValue());
synchronized (game) {
game.notify();
}
} else if (selectedArmy != null && getMouseCell().getInsideArmy() == null) {
Cell cell = getMouseCell();
if (!game.getWhoIsHisTurn().canMove(selectedCell, cell)) {
setPopUp("Invalid Cell");
return;
}
runSound.play();
game.getWhoIsHisTurn().moveArmy(selectedCell, cell);
selectedCell = null;
selectedArmy = null;
} else if (selectedCellHand != null && getMouseCell().getInsideArmy() == null) {
// Cell cell = getMouseCell();
// if(game.getWhoIsHisTurn().moveFromHandToCell(handCards.get(selectedCellHand), cell));
// handCards.put(selectedCellHand, null);
// selectedCellHand = null;
} else if (selectedArmy != null && getMouseCell().getInsideArmy() != null) {
Cell cell = getMouseCell();
Army target = cell.getInsideArmy();
if (game.getWhoIsHisTurn().isInRange(selectedCell, cell)) {
attackSound.play();
animations.get(selectedArmy).attack();
if (game.getWhoIsHisTurn().isInRange(cell, selectedCell))
animations.get(target).attack();
}
game.getWhoIsHisTurn().attack(selectedCell, cell);
if (selectedCell.getInsideArmy().getHp() <= 0) {
animations.get(selectedArmy).death();
game.setupCardDeaf(selectedCell);
}
if (cell.getInsideArmy().getHp() <= 0) {
animations.get(target).death();
game.setupCardDeaf(cell);
}
selectedCell = null;
selectedArmy = null;
} else if (heroSpSelected) {
game.getWhoIsHisTurn().useSpecialPower(getMouseCell());
}
} else if (getMouseHandCell() != null) {
selectedCellHand = getMouseHandCell();
selectedCell = null;
selectedArmy = null;
heroSpSelected = false;
}
return;
}
public void endTurn() {
selectedCell = null;
selectedArmy = null;
Expand Down
1 change: 1 addition & 0 deletions core/src/graphic/screen/LoadingScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import graphic.main.AssetHandler;
import graphic.main.Gif;
import graphic.main.Main;
import graphic.screen.gameMenuScreens.WaitingScreen;

import java.awt.*;

Expand Down
8 changes: 5 additions & 3 deletions core/src/graphic/screen/LoginScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@
import com.badlogic.gdx.InputProcessor;
import com.badlogic.gdx.audio.Music;
import com.badlogic.gdx.graphics.Texture;
import com.badlogic.gdx.graphics.g2d.*;
import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.glutils.ShapeRenderer;
import com.badlogic.gdx.math.Vector2;
import graphic.Others.SlotType;
import graphic.main.AssetHandler;
import graphic.main.Button;
import graphic.main.Main;
import model.other.Account;
import network.Client;

import java.awt.*;

Expand Down Expand Up @@ -119,7 +121,7 @@ else if (currentSlot.equals(SlotType.PASSWORD) && signUpButton.isActive())
}
}
if (loginButton.isActive() && Account.doesAccountExist(userName)) {
if (Account.checkIfPasswordIsCorrect(userName,password)) {
if (Client.logIn(userName, password).equals("correct login")) {
Account.setCurrentAccount(Account.findAccount(userName));
ScreenManager.setScreen(new MenuScreen());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public boolean touchDown(int screenX, int screenY, int pointer, int button) {
if (button != Input.Buttons.LEFT)
return false;
if (multiPlayerButton.isActive())
ScreenManager.setScreen(new MultiPlayerMenuScreen());
ScreenManager.setScreen(new MultiPlayerScreen());
if (storyButton.isActive())
ScreenManager.setScreen(new StoryMenuScreen());
if (customButton.isActive())
Expand Down
34 changes: 34 additions & 0 deletions core/src/graphic/screen/gameMenuScreens/Datas.java
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ public Deck setDeck(Deck deck) {
}
return copyDeck;
}

public void makeKillHeroCustom(int deckNumber) {
type = GameType.KILL_HERO;
Account account;
Expand Down Expand Up @@ -245,4 +246,37 @@ public void run() {
}).start();

}
public void makeKillHeroCustom(final Account account) {
type = GameType.KILL_HERO;
secondAccount = account;
new Thread(new Runnable() {
@Override
public void run() {
playGame(0);
}
}).start();
}

public void makeCaptureTheFlagCustom(Account account) {
type = GameType.CAPTURE_THE_FLAG;
secondAccount = account;
new Thread(new Runnable() {
@Override
public void run() {
playGame(1);
}
}).start();
}

public void makeRollUpFlagCustom(Account account, final int numberOfFlags) {
type = GameType.ROLLUP_FLAGS;
secondAccount = account;
new Thread(new Runnable() {
@Override
public void run() {
playGame(numberOfFlags);
}
}).start();
}

}
Loading