Gamers' Lounge :  forum
Arrange meeting times for new games, discuss past games and strategies, socialize with other players. 
Capital Choser (Java needs to converted into shockwave)
Posted by: Paars ()
Date: September 16, 2010 02:27AM

Ok created the working code to make it possible to Chose Capitals, however its coded in Java so needs to be translated into Shockwave Code.(Shouldn't be so hard for an admin, or im willing to do it if I get the current code of the ConquerorGame)

Included an image as example how it could be done.
Included an executable jar file to show how it works, its Packed in Rar so you need winrar to extract the map/file.
Download can be found HERE: [www.megaupload.com]

And here's the code for the ones interested. And yes, again I've used a lot of my previous coding.

/*
Author: Paars


Writing into class file pretty much the idea how to make a cap choser,
haven´t seen the shockwave conquerorgame game coding, nor do I use shockwave coding so I ll do it in Java.
Once again I can use most of the fairCongame code I created before.

*/

import javax.swing.*;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.io.IOException;

public class Main implements MouseListener// This Constructor would at least need the amount of Players given, probably some extra info too I don't know about
{

JFrame jFrame; // our Frame to build on
JButton cancelButton, resetButton ,acceptButton;
JComboBox[] jComboBoxArray; // ScrollBars, will be filled up with CountryNames
JTextField errorTextField; // In case of Errors, lets write them down to screen for the host to see
String[] countryNameString; // We need this Array for filling up the Scrollbars
int amountCountries =6; // temporary

/*
Temporary button and textfield since Conquerorgame provide its own ones
*/
JButton tempButton=new JButton("Start");
JTextField tempField=new JTextField("6");


class Country // I just created a nested class into my Main file
{
String countryName;
Country[] neighborArray; // Using an Array, Arraylist or a Vector could be used as well.

public Country(String countryName) // Countries constructor, all we need is a Countryname at Creating
{
this.countryName = countryName;
}
public void addNeighbors(Country[] neighborArray) // function to add the Countryneighbors, send in an array
{
this.neighborArray = neighborArray;
}
public String getCountry() // Get CountryName
{
return countryName;
}
public Country[] getNeighbors() // getNeighborArray
{
return neighborArray;
}
}

Country[] allCountriesArray;
Country[] neighborArray;

public Main() // Dunno what the class is when pressing create new game is, but after that i'd suggest a new or extra Option screen with this as constructor
{
/*
Temporarily Player Number selection, for conquerorgame has its own for that
*/
jFrame = new JFrame();
jFrame.setBounds(300,300,400,400);
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
jFrame.setLayout(null);
jFrame.setTitle("Not important Title, Conquerorgame has its own");
jFrame.setVisible(true);

tempButton.addMouseListener(this);
tempButton.setBounds(125,200,125,25);

tempField.setBounds(125,250,125,25);

jFrame.add(tempField);
jFrame.add(tempButton);

}

public void buildRealScreen()
{
Country Morocco=new Country("Morocco");Country Tangiers=new Country("Tangiers");Country Algiers=new Country("Algiers");Country Tunis=new Country("Tunis");Country Tripoli=new Country("Tripoli");Country Cyrenaica=new Country("Cyrenaica");Country Egypt=new Country("Egypt");Country Palestine=new Country("Palestine");Country Syria=new Country("Syria");Country Cyprus=new Country("Cyprus");
Country Natolia=new Country("Natolia");Country Nicaea=new Country("Nicaea");Country Crete=new Country("Crete");Country Greece=new Country("Greece");Country Macedonia=new Country("Macedonia");Country Byzantium=new Country("Byzantium");Country Bulgaria=new Country("Bulgaria");Country Moldavia=new Country("Moldavia");Country Crimea=new Country("Crimea");Country Ukraine=new Country("Ukraine");
Country Muscovy=new Country("Muscovy");Country Finland=new Country("Finland");Country Sweden=new Country("Sweden");Country Norway=new Country("Norway");Country Scotland=new Country("Scotland");Country Ulster=new Country("Ulster");Country Eire=new Country("Eire");Country Wales=new Country("Wales");Country Northumberland=new Country("Northumberland");Country England=new Country("England");
Country Brittany=new Country("Brittany");Country Gascony=new Country("Gascony");Country Castile=new Country("Castile");Country Leon=new Country("Leon");Country Portugal=new Country("Portugal");Country Aragon=new Country("Aragon");Country Aquataine=new Country("Aquataine");Country Iledefrance=new Country("Iledefrance");Country Normandy=new Country("Normandy");
Country Flanders=new Country("Flanders");Country Holland=new Country("Holland");Country Luxembourg=new Country("Luxembourg");Country Burgundy=new Country("Burgundy");Country Provence=new Country("Provence");Country Corsica=new Country("Corsica");Country Sardinia=new Country("Sardinia");Country Sicilia=new Country("Sicilia");Country Napoli=new Country("Napoli");
Country Roma=new Country("Roma");Country Genoa=new Country("Genoa");Country Helvetica=new Country("Helvetica");Country Rhineland=new Country("Rhineland");Country Saxony=new Country("Saxony");Country Hannover=new Country("Hannover");Country Denmark=new Country("Denmark");Country Brandenburg=new Country("Brandenburg");Country Bohemia=new Country("Bohemia");
Country Austria=new Country("Austria");Country Venetia=new Country("Venetia");Country Dalmatia=new Country("Dalmatia");Country Hungary=new Country("Hungary");Country Poland=new Country("Poland");Country Transylvania=new Country("Transylvania");Country Serbia=new Country("Serbia");Country Wallachia=new Country("Wallachia");Country Prussia=new Country("Prussia");
Country Podolia=new Country("Podolia");Country Lithuania=new Country("Lithuania");Country Livonia=new Country("Livonia");Country Grenada=new Country("Grenada");

// Adding all the countries in an array, easier to loop through.
allCountriesArray = new Country[]
{
Morocco,Tangiers,Algiers,Tunis,Tripoli,Cyrenaica,Egypt,Palestine,Syria,
Cyprus,Natolia,Nicaea,Crete,Greece,Macedonia,Byzantium,Bulgaria,Moldavia,Crimea,Ukraine,Muscovy,Finland,
Sweden,Norway,Scotland,Ulster,Eire,Wales,Northumberland,England,Brittany,Gascony,Castile,
Leon,Portugal,Aragon,Aquataine,Iledefrance,Normandy,Flanders,Holland,Luxembourg,Burgundy,
Provence,Corsica,Sardinia,Sicilia,Napoli,Roma,Genoa,Rhineland,Helvetica,Saxony,Hannover,Denmark,Brandenburg,
Bohemia,Austria,Venetia,Dalmatia,Hungary,Poland,Transylvania,Serbia,Wallachia,Prussia,Podolia,Lithuania,Livonia,
Grenada
};

// Adding all the neighbors to all Countries

Morocco.addNeighbors(new Country[]{Tangiers});
Tangiers.addNeighbors(new Country[]{Morocco, Grenada, Algiers});
Algiers.addNeighbors(new Country[]{Tangiers, Tunis});
Tunis.addNeighbors(new Country[]{Algiers, Tripoli, Sicilia, Sardinia});
Tripoli.addNeighbors(new Country[]{Tunis, Cyrenaica});
Cyrenaica.addNeighbors(new Country[]{Tunis, Egypt});
Egypt.addNeighbors(new Country[]{Cyrenaica, Palestine});
Palestine.addNeighbors(new Country[]{Egypt, Syria, Cyprus});
Syria.addNeighbors(new Country[]{Palestine, Cyprus, Natolia});
Cyprus.addNeighbors(new Country[]{Palestine, Syria, Natolia});
Natolia.addNeighbors(new Country[]{Cyprus, Syria, Nicaea});
Nicaea.addNeighbors(new Country[]{Natolia, Crete, Greece, Byzantium});
Crete.addNeighbors(new Country[]{Greece, Nicaea});
Greece.addNeighbors(new Country[]{Crete, Nicaea, Macedonia});
Macedonia.addNeighbors(new Country[]{Crete, Nicaea, Byzantium, Bulgaria, Napoli, Dalmatia, Serbia});
Byzantium.addNeighbors(new Country[]{Macedonia, Nicaea, Bulgaria,});
Bulgaria.addNeighbors(new Country[]{Byzantium, Macedonia, Serbia, Wallachia, Moldavia});
Moldavia.addNeighbors(new Country[]{Byzantium, Wallachia, Transylvania, Poland, Podolia, Ukraine, Crimea});
Crimea.addNeighbors(new Country[]{Moldavia, Ukraine});
Ukraine.addNeighbors(new Country[]{Crimea, Moldavia, Lithuania, Muscovy, Podolia});
Muscovy.addNeighbors(new Country[]{Ukraine, Lithuania, Livonia, Finland});
Finland.addNeighbors(new Country[]{Muscovy, Sweden});
Sweden.addNeighbors(new Country[]{Finland, Denmark, Norway});
Norway.addNeighbors(new Country[]{Sweden, Denmark, Scotland});
Scotland.addNeighbors(new Country[]{Norway, Ulster, Northumberland});
Ulster.addNeighbors(new Country[]{Scotland, Eire, Wales, Northumberland});
Eire.addNeighbors(new Country[]{Ulster, Wales});
Wales.addNeighbors(new Country[]{Eire, Ulster, Northumberland, England});
Northumberland.addNeighbors(new Country[]{Wales, Scotland, Ulster, England});
England.addNeighbors(new Country[]{Northumberland, Wales, Brittany, Normandy, Flanders, Holland});
Brittany.addNeighbors(new Country[]{England, Gascony, Iledefrance, Normandy});
Gascony.addNeighbors(new Country[]{Brittany, Aquataine, Iledefrance, Aragon, Castile});
Castile.addNeighbors(new Country[]{Gascony, Leon, Aragon, Grenada});
Leon.addNeighbors(new Country[]{Castile, Grenada, Portugal});
Portugal.addNeighbors(new Country[]{Leon, Grenada});
Aragon.addNeighbors(new Country[]{Grenada, Castile, Gascony, Aquataine});
Aquataine.addNeighbors(new Country[]{Aragon, Gascony, Iledefrance, Provence});
Iledefrance.addNeighbors(new Country[]{Aquataine, Brittany, Normandy, Burgundy, Provence, Gascony});
Normandy.addNeighbors(new Country[]{Iledefrance, England, Brittany, Flanders, Burgundy, Luxembourg});
Flanders.addNeighbors(new Country[]{Normandy, England, Holland, Luxembourg});
Holland.addNeighbors(new Country[]{Flanders, England, Hannover, Saxony});
Luxembourg.addNeighbors(new Country[]{Holland, Normandy, Flanders, Saxony, Burgundy, Rhineland, Helvetica});
Burgundy.addNeighbors(new Country[]{Luxembourg, Iledefrance, Provence, Helvetica, Genoa, Normandy});
Provence.addNeighbors(new Country[]{Burgundy, Aquataine, Iledefrance, Genoa, Corsica});
Corsica.addNeighbors(new Country[]{Provence, Genoa, Roma, Sardinia});
Sardinia.addNeighbors(new Country[]{Corsica, Tunis});
Sicilia.addNeighbors(new Country[]{Tunis, Napoli});
Napoli.addNeighbors(new Country[]{Sicilia, Roma, Macedonia});
Roma.addNeighbors(new Country[]{Napoli, Corsica, Genoa, Venetia});
Genoa.addNeighbors(new Country[]{Roma, Corsica, Provence, Burgundy, Helvetica, Venetia});
Helvetica.addNeighbors(new Country[]{Genoa, Burgundy, Luxembourg, Rhineland, Austria, Venetia});
Rhineland.addNeighbors(new Country[]{Helvetica, Luxembourg, Saxony, Bohemia, Austria});
Saxony.addNeighbors(new Country[]{Rhineland, Luxembourg, Holland, Hannover, Brandenburg, Bohemia});
Hannover.addNeighbors(new Country[]{Saxony, Holland, Denmark, Brandenburg});
Denmark.addNeighbors(new Country[]{Hannover, Norway, Sweden});
Brandenburg.addNeighbors(new Country[]{Hannover, Saxony, Bohemia, Poland});
Bohemia.addNeighbors(new Country[]{Brandenburg, Saxony, Rhineland, Austria, Poland, Hungary});
Austria.addNeighbors(new Country[]{Bohemia, Rhineland, Helvetica, Venetia, Hungary, Dalmatia});
Venetia.addNeighbors(new Country[]{Austria, Genoa, Roma, Dalmatia, Helvetica});
Dalmatia.addNeighbors(new Country[]{Venetia, Austria, Hungary, Serbia, Macedonia});
Hungary.addNeighbors(new Country[]{Dalmatia, Austria, Poland, Transylvania, Serbia, Bohemia});
Poland.addNeighbors(new Country[]{Hungary, Brandenburg, Moldavia, Podolia, Prussia, Transylvania, Bohemia});
Transylvania.addNeighbors(new Country[]{Poland, Hungary, Serbia, Wallachia, Moldavia});
Serbia.addNeighbors(new Country[]{Transylvania, Wallachia, Bulgaria, Macedonia, Dalmatia, Hungary});
Wallachia.addNeighbors(new Country[]{Serbia, Transylvania, Moldavia, Bulgaria});
Prussia.addNeighbors(new Country[]{Poland, Podolia, Lithuania});
Podolia.addNeighbors(new Country[]{Prussia, Poland, Moldavia, Lithuania, Ukraine});
Lithuania.addNeighbors(new Country[]{Podolia, Livonia, Muscovy, Ukraine , Prussia});
Livonia.addNeighbors(new Country[]{Lithuania, Muscovy});
Grenada.addNeighbors(new Country[]{Tangiers, Portugal, Leon, Castile, Aragon});

// Coding for the standard Frame
jComboBoxArray = new JComboBox[amountCountries]; // Create the right amount of dropdownmenu's

jFrame=new JFrame();
jFrame.setBounds(0,0,1000,800); // setFrameSize 0 px from top and 0 px from left with width 1000px, height 800px,function getScreenSize could be used too
jFrame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // must be able to close it
jFrame.setLayout(null); // no layout, we will be positioning absolute ourselves.

// Lets add the ScrollbarArray, using a loop to add them to the JFrame.
// First fill Up the CountryNameArray using a loop so it can be used for the scrollbars
countryNameString =new String[allCountriesArray.length]; // Make sure the arrays are the same size
for(int i=0;i < allCountriesArray.length;i++)
{
countryNameString = allCountriesArray.getCountry(); //
}

int j=0; // just an extra into to place the Scrollbars next to each other
for(int i=0;i < amountCountries; i++) // loop from 0 to obviously chosenCountriesAmount
{
jComboBoxArray = new JComboBox(countryNameString);
jComboBoxArray.setSelectedIndex(allCountriesArray.length-1);
jComboBoxArray.addMouseListener(this);
jComboBoxArray.setSize(125,35);
if(i<8)
jComboBoxArray.setLocation(225,125+i*50);
else
{
jComboBoxArray.setLocation(425,125+j*50);
j++;
}
jFrame.add(jComboBoxArray);

}

// adding the buttons

acceptButton = new JButton("accept"); // continue
resetButton = new JButton("reset"); // Reset The scrollBars, kinda unnessecary but I had a diffrent plan first
cancelButton = new JButton("Cancel"); // return

acceptButton.setBounds(100,650,150,30);
resetButton.setBounds(300,650,150,30);
cancelButton.setBounds(500,650,150,30);

acceptButton.addMouseListener(this);
resetButton.addMouseListener(this);
cancelButton.addMouseListener(this);

jFrame.add(acceptButton);
jFrame.add(resetButton);
jFrame.add(cancelButton);

errorTextField=new JTextField("Status field::");
errorTextField.setBounds(50,710,700,30);
errorTextField.setEditable(false);

jFrame.add(errorTextField); // Is actually statusfield

jFrame.setTitle("Capital picker version 1.0 (Java) for ConquerorGame");
jFrame.setVisible(true);
}

public void mouseClicked(MouseEvent e)
{
// Since I implemented MouseListener, I'm forced to also create/implements all its functions
}

public void mousePressed(MouseEvent e)
{
// Since I implemented MouseListener, I'm forced to also create/implements all its functions
}

public void mouseReleased(MouseEvent e)
{
if(e.getSource() == acceptButton)
{
boolean done=false;
Country[] chosenCapitalArray = new Country[amountCountries];
Country[] tempNeighbors=null;
for(int i=0;i < amountCountries;i++)
{
for(int j=0;j < allCountriesArray.length;j++)
{
if(jComboBoxArray.getSelectedItem().equals(allCountriesArray[j].getCountry()) && i != j)
{
chosenCapitalArray = allCountriesArray[j];
System.out.println("ChosenCap Found at pos: "+chosenCapitalArray.getCountry()+":"+i +": And "+allCountriesArray[j].getCountry()+":"+j );
}
}
}
for(int i=0;i < amountCountries;i++)
{
tempNeighbors = chosenCapitalArray.getNeighbors();
for(int j=0;j < amountCountries;j++)
{
if(chosenCapitalArray.getCountry().equals(chosenCapitalArray[j].getCountry()) && i != j )
{
errorTextField.setText("Error: Double capitals " + chosenCapitalArray.getCountry() + " Is chosen twice");
done=true;
break;
}
for(int k=0;k < tempNeighbors.length;k++)
{
if(chosenCapitalArray[j].getCountry().equals(tempNeighbors[k].getCountry()))
{
errorTextField.setText("Status Field: "+chosenCapitalArray.getCountry() + " to close to "+ tempNeighbors[k].getCountry());
done=true;
break;
}
}
}
}
if(!done)
{
errorTextField.setText("Status field: You've accepted, Do error Checking, gather info and continue");
// -> Now continue further to where players select their capitals.Send the Array of none Random Capital }
}
}
if(e.getSource() == resetButton)
{
errorTextField.setText("Status field: Reset button, not nessecary");
}
if(e.getSource() == cancelButton)
{
errorTextField.setText("Status field: Canceled -> Close Screen and return");
}
if(e.getSource() == tempButton)
{
try
{
int playerNumber =Integer.parseInt(tempField.getText());
if(playerNumber < 17 && playerNumber > 1)
{
amountCountries = playerNumber;
buildRealScreen();
}
}
catch(Exception exc)
{
//because I have to throw an Exception
};
}
}

public void mouseEntered(MouseEvent e)
{
// Since I implemented MouseListener, I'm forced to also create/implements all its functions
}

public void mouseExited(MouseEvent e)
{
// Since I implemented MouseListener, I'm forced to also create/implements all its functions
}

// public static void main is the standard Java function to run a program, in conquerorGame needs to be switched since its not the file to run.
public static void main(String[]args)
{
new Main(); // Create new Object of this class
}

}



Paars



Edited 1 time(s). Last edit at 09/16/2010 03:14AM by Paars.

Attachments: example.jpg (65.6 KB)  
Options: ReplyQuote
Re: Capital Choser (Java needs to converted into shockwave)
Posted by: LikeNoOthers ()
Date: September 16, 2010 05:21AM

I support this!

Options: ReplyQuote
Re: Capital Choser (Java needs to converted into shockwave)
Posted by: sixamplayer ()
Date: September 16, 2010 05:52AM

you also support the clubbing of baby seals!

Options: ReplyQuote
Re: Capital Choser (Java needs to converted into shockwave)
Posted by: Roddy ()
Date: September 16, 2010 11:03AM

This would be an excellent feature for conqeuror, i really hope it can be implemented

KrazyKat

Options: ReplyQuote
Re: Capital Choser (Java needs to converted into shockwave)
Posted by: Akiran ()
Date: September 18, 2010 01:27PM

:)

M-K

Options: ReplyQuote
Re: Capital Choser (Java needs to converted into shockwave)
Posted by: Roddy ()
Date: September 23, 2010 05:51AM

Paars,

Does this code allow the host or the individual player to select the starting capitals?

KrazyKat

Options: ReplyQuote
Re: Capital Choser (Java needs to converted into shockwave)
Posted by: Paars ()
Date: September 23, 2010 06:41AM

This would be a pre-starting screen for the host to chose from.
I've Emailed alexey about it, he mailed me back with asking similair question and some other info. I replied again but I've not heard back from him back yet.

Paars

Options: ReplyQuote
Re: Capital Choser (Java needs to converted into shockwave)
Posted by: Roddy ()
Date: September 23, 2010 08:09AM

Thats good to hear, sounds like he is thinking about it at least.

KrazyKat

Options: ReplyQuote
Re: Capital Choser (Java needs to converted into shockwave)
Posted by: Paars ()
Date: September 23, 2010 10:15AM

Yeah I will email again soon, also suggested myself getting the conquerorgame coding and implement it myself.

Options: ReplyQuote
Re: Capital Choser (Java needs to converted into shockwave)
Posted by: Roddy ()
Date: October 29, 2010 04:19PM

I have a secret hope that the Conqueror server is down coz this is getting implemented

KrazyKat

Options: ReplyQuote
Re: Capital Choser (Java needs to converted into shockwave)
Posted by: Paars ()
Date: October 30, 2010 12:19PM

The server wouldn´t have to be out to implement that update, usually they use a second page to test new features like that. Then it takes a few second restart of server to update / to implement it to the real version.

Options: ReplyQuote


Sorry, only registered users may post in this forum.