]> git.zerfleddert.de Git - FreeShisen/blame - src/org/proofofconcept/shisensho/ShisenSho.java
remove generated files
[FreeShisen] / src / org / proofofconcept / shisensho / ShisenSho.java
CommitLineData
c6f3dff3 1package org.proofofconcept.shisensho;
2
3import java.util.Observable;
4import java.util.Observer;
5
6import android.app.Application;
7import android.os.Bundle;
8import android.util.Log;
9
10public class ShisenSho extends Application {
11 private static ShisenSho instance = null;
12 private ShisenShoView view = null;
13 public ShisenShoActivity activity = null;
14
15 public Board board;
16 public int[] boardSize=new int[2];
17 public int difficulty=1; // 1=Hard, 2=Easy
18 public int size=3; // 1=Small, 2=Medium, 3=Big
19 public boolean gravity=true;
20 public boolean timeCounter=true;
21
22 public static void log(String msg) {
23 Log.w("ShisenSho", msg);
24 }
25
26 public void newPlay() {
27 board = new Board();
28 board.buildRandomBoard(boardSize[0],boardSize[1],difficulty,gravity);
29 }
30
31 public void setSize(int s) {
32 switch (s) {
33 case 1:
34 size=1;
35 boardSize[0]=6+2;
36 boardSize[1]=8+2;
37 break;
38 case 2:
39 size=2;
40 boardSize[0]=6+2;
41 boardSize[1]=12+2;
42 break;
43 case 3:
44 default:
45 size=3;
46 boardSize[0]=6+2;
47 boardSize[1]=16+2;
48 break;
49 }
50 }
51
52 public void sleep(int deciSeconds) {
53 try {
54 Thread.sleep(deciSeconds*100);
55 } catch (InterruptedException e) { }
56 }
57
58 public ShisenSho() {
59 instance = this;
60 setSize(size);
61 }
62
63 public static synchronized ShisenSho app() {
64 return instance;
65 }
66
67 public ShisenShoView getView() {
68 if (view == null) view = new ShisenShoView(this);
69 return view;
70 }
71
72 /** Called when the activity is first created. */
73 @Override
74 public void onCreate() {
75 super.onCreate();
76 }
77
78 public Bundle getOptions() {
79 Bundle options = new Bundle();
80 options.putInt("size", size);
81 options.putInt("difficulty", difficulty);
82 options.putBoolean("gravity", gravity);
83 options.putBoolean("timeCounter", timeCounter);
84 return options;
85 }
86
87 public void setOptions(Bundle options) {
88 int size = options.getInt("size");
89 int difficulty = options.getInt("difficulty");
90 boolean gravity = options.getBoolean("gravity");
91 boolean timeCounter = options.getBoolean("timeCounter");
92
93 boolean needsReset = false;
94
95 if (size != this.size) {
96 setSize(size);
97 needsReset = true;
98 }
99
100 if (difficulty != this.difficulty) {
101 this.difficulty = difficulty;
102 needsReset = true;
103 }
104
105 if (gravity != this.gravity) {
106 this.gravity = gravity;
107 needsReset = true;
108 }
109
110 if (timeCounter != this.timeCounter) {
111 this.timeCounter = timeCounter;
112 view.onTimeCounterActivate();
113 }
114
115 if (needsReset) {
116 view.reset();
117 }
118 }
119
120}
Impressum, Datenschutz