Permalink
Browse files

Some cleanup, some functions to try to outline online play

  • Loading branch information...
1 parent 3dab13b commit e70feb20fcfc5114f06d1f83f21de2a774cc6e0a @Neugebauer committed Feb 16, 2012
Showing with 36 additions and 24 deletions.
  1. +36 −24 src/com/example/thor/threeby3/ThreeBy3Activity.java
@@ -60,7 +60,7 @@
private static boolean sound = true;
private static MediaPlayer trashTalk;
public Random rand = new Random();
- private static final String SERVLET_URL = "http://";
+ //private static final String SERVLET_URL = "http://";
public boolean online = false;
//private static final String TAG = "MyActivity";
@@ -127,10 +127,11 @@ public void onCheckedChanged(CompoundButton arg0, boolean arg1) {
@Override
protected void onResume() {
super.onResume();
-// if (!firstOnResume)
+ try{
loadGame("ORIENTHOLD");
-// else
-// firstOnResume = false;
+ }catch(NullPointerException e){
+ startOver();
+ }
sensMgr.registerListener(this, accelerometer, SensorManager.SENSOR_DELAY_NORMAL);
}
@@ -147,14 +148,35 @@ protected void onSaveInstanceState (Bundle outState) {
}
+ public void playOnlineRegister() {
+ //createGameKey
+ //InsertGameKeyToGamesTableOfServletDB
+ //WaitForOpponentToArrive
+ }
public void playOnline() {
online = true;
- //createGameKey
- //InsertGameKeyToGamesTableOfServletDB
- //DisableButtons
+ //DisableXOButtons
//WaitForServletToSayItsYourMove
}
+
+ public void waitForOpponentsMove() {
+ //QueryServletDB
+ //Button.click()
+ buttonsClickable(true);
+ }
+
+ public void reportMove(Integer squareid) {
+ //InsertMoveToMovesTableOfServletDB
+ }
+
+ public void buttonsClickable(boolean clickable) {
+ Button button;
+ for (Integer squareid : squares) {
+ button = (Button) findViewById(squareid);
+ button.setClickable(clickable);
+ }
+ }
//When button is clicked
public void claimSquare(View view) {
@@ -230,28 +252,18 @@ public void claimSquare(View view) {
playername = (playername.equals("X")) ? "O" : "X";
showWhoseTurn();
if (playername.equals("O") && computeropponent == true)
- computerMove();
-
-// // SLEEP 1 SEC
-// Handler handler = new Handler();
-// handler.postDelayed(new Runnable() {
-// public void run() {
-//
-// if (toe) {
-// if (moves == 3 || moves == 6)
-// playToe();
-// if (moves == 4 || moves == 7)
-// cleanToe();
-// }
-// }
-// }, 1000);
-
- if (toe) {
+ computerMove();
+ else if (toe) {
if (moves == 3 || moves == 6)
playToe();
if (moves == 4 || moves == 7)
cleanToe();
}
+ else if (online) {
+ buttonsClickable(false);
+ reportMove(squareid);
+ waitForOpponentsMove();
+ }
}
}
}

0 comments on commit e70feb2

Please sign in to comment.