/*
* Copyright (c) 2014 Jack Andrew Loudon, All Rights Reserved.
* Author: Jack Andrew Loudon, 2014
*/
package com.github.bewd.yugioh.main;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.IOException;
import java.math.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.Random;
import java.util.Scanner;
import java.util.logging.Logger;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
import javax.swing.JPanel;
@SuppressWarnings("serial")
public class Main extends JPanel{
public static final String imgPathCard = "img\\cards\\";
public static final String imgPathLogo = "img\\logos\\";
public static final String fontPath = "fonts\\";
private static final int appVersionMajor = 0;
private static final double appVersionMinor = 1.3;
private static final String appName = "Yu-Gi-Oh!: Trading Card Game";
private static final String appStage = "Alpha";
private static final String versionString = appName + " (" + appVersionMajor + "." + appVersionMinor + " " + appStage + ")";
private BufferedImage sdk1, sdk2, sdk3, sdk4, sdk5, sdk6, sdk7, sdk8, sdk9, sdk10, bc;
public Main() {
try {
sdk1 = ImageIO.read(getClass().getResourceAsStream(imgPathCard + "sdk001.png"));
sdk2 = ImageIO.read(getClass().getResourceAsStream(imgPathCard + "sdk002.png"));
sdk3 = ImageIO.read(getClass().getResourceAsStream(imgPathCard + "sdk003.png"));
sdk4 = ImageIO.read(getClass().getResourceAsStream(imgPathCard + "sdk004.png"));
sdk5 = ImageIO.read(getClass().getResourceAsStream(imgPathCard + "sdk005.png"));
}
catch (IOException e) {
Logger LogErr = Logger.getLogger(Main.class.getName());
System.err.println(appName + " " + "Caught IOException: " + e.getMessage());
}
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(sdk1, 0, 0, Card.cardwidth / 5, Card.cardheight / 5, null);
g.drawImage(sdk2, Card.cardlong, 0, Card.cardwidth / 5, Card.cardheight / 5, null);
g.drawImage(sdk3, Card.cardlong * 2, 0, Card.cardwidth / 5, Card.cardheight / 5, null);
g.drawImage(sdk4, Card.cardlong * 3, 0, Card.cardwidth / 5, Card.cardheight / 5, null);
g.drawImage(sdk5, Card.cardlong * 4, 0, Card.cardwidth / 5, Card.cardheight / 5, null);
}
public static void main(String[] args) {
JFrame frame = new JFrame(versionString);
frame.setSize(1020, 680);
frame.setVisible(true);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setExtendedState(JFrame.MAXIMIZED_BOTH);
ArrayList<MonsterCard> deck1 = new ArrayList(50);
ArrayList<MonsterCard> deck2 = new ArrayList(50);
deck1.add(CardListKaiba.BlueEyesWhiteDragon);
deck1.add(CardListKaiba.HitotsuMeGiant);
deck1.add(CardListKaiba.RyuKishin);
deck1.add(CardListKaiba.TheWickedWormBeast);
deck1.add(CardListKaiba.BattleOx);
deck1.add(CardListKaiba.KoumoriDragon);
deck1.add(CardListKaiba.JudgeMan);
deck1.add(CardListKaiba.RogueDoll);
deck1.add(CardListKaiba.Kojikocy);
deck1.add(CardListKaiba.Uraby);
deck2.add(CardListYugi.MysticalElf); //Other Player
deck2.add(CardListYugi.FeralImp);
deck2.add(CardListYugi.WingedDragon1);
deck2.add(CardListYugi.SummonedSkull);
deck2.add(CardListYugi.BeaverWarrior);
deck2.add(CardListYugi.DarkMagician);
deck2.add(CardListYugi.Gaia);
deck2.add(CardListYugi.CurseOfDragon);
deck2.add(CardListYugi.CelticGuardian);
deck2.add(CardListYugi.MammothGraveyard); //End Of Other Player
ArrayList<MonsterCard> monsterfield1 = new ArrayList(5);
ArrayList<MonsterCard> monsterfield2 = new ArrayList(5);
ArrayList<SpellCard> magicfield1 = new ArrayList(5);
ArrayList<SpellCard> magicfield2 = new ArrayList(5);
ArrayList<MonsterCard> hand1 = new ArrayList(5);
ArrayList<MonsterCard> hand2 = new ArrayList(5);
int lifepoints1 = 2000;
int lifepoints2 = 2000;
Random r = new Random();
int randomPos1 = r.nextInt(deck1.size());
int randomPos2 = r.nextInt(deck2.size());
int drawHandSize = 3;
System.out.println("Drawing Hand from Deck...");
for(int playerOneDraw = -1; playerOneDraw < drawHandSize; playerOneDraw++){
hand1.add(deck1.get(randomPos1));
deck1.remove(randomPos1);
}
for(int playerTwoDraw = -1; playerTwoDraw < drawHandSize; playerTwoDraw++){
hand2.add(deck2.get(randomPos2));
deck2.remove(randomPos2);
}
while(lifepoints1 > 0|| lifepoints2 > 0){
hand1.add(deck1.get(randomPos1));
deck1.remove(randomPos1);
System.out.println("Initiating Draw Phase:");
System.out.println("Your hand consists of:");
for(int i = 0; i < hand1.size(); i++){
System.out.println(hand1.get(i).toString() + "");
}
System.out.println("Initiating Main Phase 1:");
System.out.println("Which monster would you like to summon?");
Scanner monSummon = new Scanner(System.in);
int whichMonsterPOS1 = monSummon.nextInt();
monsterfield1.add(hand1.get(whichMonsterPOS1));
hand1.remove(whichMonsterPOS1);
for(int i = 0; i<monsterfield1.size(); i++){
System.out.println(monsterfield1.get(i).toString() + " has been summoned");
}
frame.setVisible(true);
System.out.println("Your side of the Field contains: " + monsterfield1);
break;
}
}
}