diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 074d7f4..23ec069 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -20,6 +20,12 @@
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/ic_launcher-web.png b/app/src/main/ic_launcher-web.png
new file mode 100644
index 0000000..b36b0a6
Binary files /dev/null and b/app/src/main/ic_launcher-web.png differ
diff --git a/app/src/main/java/com/example/denis/fightclub/GameActivity.java b/app/src/main/java/com/example/denis/fightclub/GameActivity.java
index 36cd32f..817d40e 100644
--- a/app/src/main/java/com/example/denis/fightclub/GameActivity.java
+++ b/app/src/main/java/com/example/denis/fightclub/GameActivity.java
@@ -1,284 +1,158 @@
package com.example.denis.fightclub;
import android.content.Intent;
-import android.content.SharedPreferences;
-import android.os.SystemClock;
+import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
+import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.RadioButton;
-import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
-import java.util.Objects;
-import java.util.Random;
+import com.example.denis.fightclub.entity.Enemy;
+import com.example.denis.fightclub.entity.Player;
-public class GameActivity extends AppCompatActivity {
-
- public int dPlayer [] = new int[4];
- public int aPlayer [] = new int[4];
-
- public int dEnemy [] = new int[4];
- public int aEnemy [] = new int[4];
- public int playerHealth = 100;
- public int enemyHealth = 100;
-
- public boolean gameEnd = false;
-
- private SharedPreferences session;
- public static final String Game_Session = "Session";
- public static final String Player_Health = "Player";
- public static final String Enemy_Health = "Enemy";
- public static final String Is_Game_End = "End";
+public class GameActivity extends AppCompatActivity {
- final Random random = new Random();
ProgressBar playerHealthBar;
ProgressBar enemyHealthBar;
TextView playerHealtText;
TextView enemyHealthText;
- TextView battleLog;
Button Go;
Button menu;
Button newGame;
- ScrollView logScroll;
-
- public String log = "";
+ Player player;
+ Enemy enemy;
+ ImageView playerPortrait, enemyPortrait;
+ TextView playerName,enemyName;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_game);
+ fullscreen();
+ playerName = (TextView) findViewById(R.id.playerName);
playerHealthBar = (ProgressBar) findViewById(R.id.playerHealthBar);
enemyHealthBar = (ProgressBar) findViewById(R.id.enemyHealthBar);
playerHealtText = (TextView) findViewById(R.id.playerHealth);
enemyHealthText = (TextView) findViewById(R.id.enemyHealth);
- battleLog =(TextView) findViewById(R.id.battleLog);
+ playerPortrait = (ImageView) findViewById(R.id.playerPortrait);
+ enemyPortrait = (ImageView) findViewById(R.id.enemyPortrait);
+ enemyName = (TextView) findViewById(R.id.enemyName);
menu = (Button) findViewById(R.id.Menu);
newGame = (Button) findViewById(R.id.newGame);
- logScroll = (ScrollView) findViewById(R.id.scrollLog);
Go = (Button) findViewById(R.id.Start);
Go.setClickable(true);
- dPlayer [0] = 1;
- aPlayer [0] = 1;
- session = getSharedPreferences(Game_Session,MODE_PRIVATE);
-
- if (MainActivity.isContinue == true) {
- playerHealth = session.getInt(Player_Health,0);
- enemyHealth = session.getInt(Enemy_Health,0);
- playerHealthBar.setProgress(playerHealth);
- playerHealtText.setText(""+playerHealth);
- enemyHealthBar.setProgress(enemyHealth);
- enemyHealthText.setText(""+enemyHealth);
- }
+ player = MainActivity.player;
+ //player = new Player(this);
+ playerName.setText(player.getName());
+ enemy = new Enemy(player.numberOfPoints());
+ enemyName.setText(enemy.getName(this));
+ playerHealthBar.setMax(player.getMaxHealth());
+ playerHealthBar.setProgress(player.getMaxHealth());
+ playerHealtText.setText(""+player.getMaxHealth());
+
+ Bitmap playerPort = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(),player.getPortrait()),400,426,false);
+ playerPortrait.setImageBitmap(playerPort);
+ Bitmap enemyPort = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(),enemy.getPortrait()),400,426,false);
+ enemyPortrait.setImageBitmap(enemyPort);
+ enemyHealthBar.setMax(enemy.getMaxHealth());
+ enemyHealthBar.setProgress(enemy.getMaxHealth());
+ enemyHealthText.setText(""+enemy.getMaxHealth());
}
public void gameCycle(){
- int pDamage = random.nextInt(10) + 1;
- int pDef = random.nextInt(5) + 1;
- int eDamage = random.nextInt(10) + 1;
- int eDef = random.nextInt(5) + 1;
- enemy();
- if (indexOfIntArray(aPlayer,1) == indexOfIntArray(dEnemy,1)) {
- enemyHealth = enemyHealth - (pDamage - eDef);
- if (pDamage > eDef){
- log = log + "\nYou deal: " + (pDamage - eDef) + " damage.";}
- else {log = log +"\nEnemy dodged.";}
- } else {enemyHealth = enemyHealth - pDamage;
- log = log + "\nYou deal: " + (pDamage) + " damage.";}
-
- if (indexOfIntArray(dPlayer,1) == indexOfIntArray(aEnemy,1)) {
- playerHealth = playerHealth - (eDamage - pDef);
- if (eDamage > pDef){
- log = log + "\nYou got: " + (eDamage - pDef) + " damage";
- } else { log = log +"\nYou avoided enemy hit";}
- } else {playerHealth = playerHealth - eDamage;
- log = log + "\nYou recive: " + eDamage +" damage";}
- battleLog.setText(log);
- SystemClock.sleep(100);
- //logScroll.fullScroll(View.FOCUS_DOWN);
- logScroll.scrollTo(0,logScroll.getHeight());
-
- if (playerHealth <= 0 || enemyHealth <= 0){
- end();
- }
-
+ enemy.takeDamage(player.doDamage(),player.getAttackVector());
+ player.takeDamage(enemy.doDamage(),enemy.getAttackVector());
+ if (player.getCurrentHealth() <= 0 || enemy.getHealth() <= 0)
+ {end();}
}
- public void playerRadio(View view){
+ public void defenceRadio(View view){
boolean checked = ((RadioButton) view).isChecked();
switch (view.getId()){
case R.id.playerHead:
if (checked){
- radioSwitch("Player","Head");
+ player.setDefenceVector(1);
} break;
case R.id.playerArms:
if (checked){
- radioSwitch("Player","Arm");
+ player.setDefenceVector(2);
} break;
case R.id.playerChest:
if (checked){
- radioSwitch("Player","Chest");
+ player.setDefenceVector(3);
} break;
case R.id.playerLegs:
if (checked){
- radioSwitch("Player","Leg");
+ player.setDefenceVector(4);
} break;
}
}
- public void enemyRadio (View view){
+ public void attackRadio(View view){
boolean checked = ((RadioButton) view).isChecked();
switch (view.getId()) {
case R.id.enemyHead:
if (checked){
- radioSwitch("Enemy","Head");
+ player.setAttackVector(1);
} break;
case R.id.enemyArm:
if (checked){
- radioSwitch("Enemy","Arm");
+ player.setAttackVector(2);
} break;
case R.id.enemyChest:
if (checked){
- radioSwitch("Enemy","Chest");
+ player.setAttackVector(3);
} break;
case R.id.enemyLegs:
if (checked){
- radioSwitch("Enemy","Arm");
+ player.setAttackVector(4);
}break;
}
}
- public void radioSwitch (String s, String b)
- {
- if (Objects.equals(s, "Player")){
- switch (b){
- case "Head" :
- { dPlayer [0] = 1;
- dPlayer [1] = 0;
- dPlayer [2] = 0;
- dPlayer [3] = 0;
- } break;
- case "Arm" :{
- dPlayer [0] = 0;
- dPlayer [1] = 1;
- dPlayer [2] = 0;
- dPlayer [3] = 0;
- } break;
- case "Chest" :{
- dPlayer [0] = 0;
- dPlayer [1] = 0;
- dPlayer [2] = 1;
- dPlayer [3] = 0;
- } break;
- case "Leg" :{
- dPlayer [0] = 0;
- dPlayer [1] = 0;
- dPlayer [2] = 0;
- dPlayer [3] = 1;
- } break;
- }
- }
-
- if (Objects.equals(s, "Enemy"))
- {
- switch (b){
- case "Head" :{
- aPlayer [0] = 1;
- aPlayer [1] = 0;
- aPlayer [2] = 0;
- aPlayer [3] = 0;
- } break;
- case "Arm" :{
- aPlayer [0] = 0;
- aPlayer [1] = 1;
- aPlayer [2] = 0;
- aPlayer [3] = 0;
- } break;
- case "Chest" : {
- aPlayer [0] = 0;
- aPlayer [1] = 0;
- aPlayer [2] = 1;
- aPlayer [3] = 0;
- } break;
- case "Leg" : {
- aPlayer [0] = 0;
- aPlayer [1] = 0;
- aPlayer [2] = 0;
- aPlayer [3] = 1;
- } break;
- }
- }
- }
-
public void buttonStart(View view) {
gameCycle();
- playerHealthBar.setProgress(playerHealth);
- playerHealtText.setText(""+playerHealth);
- enemyHealthBar.setProgress(enemyHealth);
- enemyHealthText.setText(""+enemyHealth);
- }
-
- public void enemy() {
- for (int i = 0; i < 4; i++ ) {
- dEnemy [i] = 0;
- aEnemy [i] = 0;
- }
- int rand1 = random.nextInt(4);
- int rand2 = random.nextInt(4);
- dEnemy [rand1] = 1;
- aEnemy [rand2] = 1;
+ playerHealthBar.setProgress(player.getCurrentHealth());
+ playerHealtText.setText("" + player.getCurrentHealth());
+ enemyHealthBar.setProgress(enemy.getHealth());
+ enemyHealthText.setText("" + enemy.getHealth());
}
-
- public static int indexOfIntArray(int[] array, int key) {
- int returnvalue = -1;
- for (int i = 0; i < array.length; ++i) {
- if (key == array[i]) {
- returnvalue = i;
- break;
- }
- }
- return returnvalue;
- }
-
- @Override
- protected void onPause() {
- super.onPause();
- if (playerHealth > 0 && enemyHealth > 0)
+ public void end() {
+ if (player.getCurrentHealth() <= 0 && enemy.getHealth() <= 0)
{
- SharedPreferences.Editor editor = session.edit();
- editor.putInt(Player_Health,playerHealth);
- editor.putInt(Enemy_Health,enemyHealth);
- editor.apply();
- gameEnd = false;
+ Toast.makeText(getApplicationContext(), "Draw", Toast.LENGTH_LONG).show();
+ Go.setClickable(false);
}
- }
-
- public void end() {
- if (playerHealth <= 0) {
+ if (player.getCurrentHealth() <= 0 && enemy.getHealth() > 0) {
Toast.makeText(getApplicationContext(), "You lose", Toast.LENGTH_LONG).show();
Go.setClickable(false);
}
- if (enemyHealth <= 0) {
+ if (enemy.getHealth() <= 0 && player.getCurrentHealth() > 0) {
Toast.makeText(getApplicationContext(), "You win", Toast.LENGTH_LONG).show();
+ if (player.isYouLucky()){
+ Toast.makeText(getApplication(),"You get an extra skill point", Toast.LENGTH_LONG).show();
+ }
+
Go.setClickable(false);
}
- SharedPreferences.Editor editor = session.edit();
- battleLog.setVisibility(View.INVISIBLE);
- gameEnd = true;
- editor.putBoolean(Is_Game_End,gameEnd);
- editor.apply();
+
+
menu.setVisibility(View.VISIBLE);
menu.setClickable(true);
newGame.setVisibility(View.VISIBLE);
@@ -291,6 +165,7 @@ public void mainMenu(View view) {
}
public void newGame(View view) {
+ player.newGame();
Intent intent = getIntent();
overridePendingTransition(0,0);
intent.addFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
@@ -298,4 +173,14 @@ public void newGame(View view) {
overridePendingTransition(0,0);
startActivity(intent);
}
+ public void fullscreen(){
+ getWindow().getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_IMMERSIVE
+ );
+}
}
diff --git a/app/src/main/java/com/example/denis/fightclub/HeroActivity.java b/app/src/main/java/com/example/denis/fightclub/HeroActivity.java
new file mode 100644
index 0000000..4e9e855
--- /dev/null
+++ b/app/src/main/java/com/example/denis/fightclub/HeroActivity.java
@@ -0,0 +1,271 @@
+package com.example.denis.fightclub;
+
+import android.content.Intent;
+import android.graphics.Color;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.text.Editable;
+import android.text.TextWatcher;
+import android.view.View;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.ImageView;
+import android.widget.TextView;
+
+
+/**
+ * Created by Denis on 10.05.2016.
+ */
+public class HeroActivity extends AppCompatActivity{
+ private String name;
+ private int strenght;
+ private int strengthTmp;
+ private int agility;
+ private int agilityTmp;
+ private int crit_chance;
+ private int critChanceTmp;
+ private int crit_mult;
+ private int critMultTmp;
+ private int luck;
+ private int luckTmp;
+ private int points;
+ private int pointTmp;
+ private int characterPortrait;
+
+ TextView playerAgility,playerStrenght,playerCritMult,playerCritChance,playerLuck,freePoints;
+ EditText playerName;
+ ImageView portrait;
+ Button setButton;
+
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_hero);
+ playerName = (EditText) findViewById(R.id.PlayerName);
+ portrait = (ImageView) findViewById(R.id.characterPortrait);
+ playerAgility = (TextView) findViewById(R.id.playerAgility);
+ playerStrenght = (TextView) findViewById(R.id.playerStrength);
+ playerCritChance = (TextView) findViewById(R.id.playerCrit);
+ playerCritMult = (TextView) findViewById(R.id.critMult);
+ playerLuck = (TextView) findViewById(R.id.playerLuck);
+ freePoints = (TextView) findViewById(R.id.freePoints);
+ setButton = (Button) findViewById(R.id.setButton);
+ getAll();
+ playerName.setBackgroundColor(Color.TRANSPARENT);
+ playerName.addTextChangedListener(new TextWatcher() {
+ @Override
+ public void beforeTextChanged(CharSequence s, int start, int count, int after) {
+
+ }
+
+ @Override
+ public void onTextChanged(CharSequence s, int start, int before, int count) {
+
+ }
+
+ @Override
+ public void afterTextChanged(Editable s) {
+ fullscreen();
+ name = playerName.getText().toString();
+ MainActivity.player.setName(name);
+ }
+ });
+ initialize();
+ fullscreen();
+ }
+
+
+
+ public void fullscreen(){
+ getWindow().getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_IMMERSIVE
+ );
+ }
+
+ private void initialize(){
+ playerStrenght.setText("" + strenght);
+ playerAgility.setText("" + agility);
+ playerCritChance.setText("" + crit_chance);
+ playerCritMult.setText("" + crit_mult);
+ playerLuck.setText("" + luck);
+ playerName.setText(name);
+ freePoints.setText("Free points: " + points);
+ portrait.setImageResource(characterPortrait);
+ strengthTmp = strenght;
+ agilityTmp = agility;
+ critChanceTmp = crit_chance;
+ critMultTmp = crit_mult;
+ luckTmp = luck;
+ pointTmp = points;
+ }
+
+ public void characterPortrait(View view) {
+ System.gc();
+ Intent intent = new Intent(HeroActivity.this,PortraitActivity.class);
+ startActivity(intent);
+ }
+
+ @Override
+ protected void onResume() {
+ super.onResume();
+ setCharacterPortrait();
+ }
+
+ @Override
+ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
+ super.onActivityResult(requestCode, resultCode, data);
+ if (requestCode == 1){
+ if (resultCode == RESULT_OK){
+ portrait = (ImageView) findViewById(R.id.characterPortrait);
+ }
+ if (requestCode == RESULT_CANCELED){
+ portrait = (ImageView) findViewById(R.id.characterPortrait);
+ }
+ }
+ portrait = (ImageView) findViewById(R.id.characterPortrait);
+ }
+
+ public void getAll(){
+ String[] tmp;
+ tmp = MainActivity.player.getAll();
+ strenght = Integer.parseInt(tmp[0]);
+ agility = Integer.parseInt(tmp[1]);
+ crit_chance = Integer.parseInt(tmp[2]);
+ crit_mult = Integer.parseInt(tmp[3]);
+ luck = Integer.parseInt(tmp[4]);
+ characterPortrait = Integer.parseInt(tmp[5]);
+ points = Integer.parseInt(tmp[6]);
+ name = tmp[7];
+ }
+
+ public void setCharacterPortrait(){
+ characterPortrait = MainActivity.player.getPortrait();
+ portrait.setImageResource(characterPortrait);
+ }
+
+ public void setButton(View view) {
+ strenght = strengthTmp;
+ agility = agilityTmp;
+ crit_chance = critChanceTmp;
+ crit_mult = critMultTmp;
+ luck = luckTmp;
+ points = pointTmp;
+ String[] tmp = {Integer.toString(strenght),Integer.toString(agility),Integer.toString(crit_chance),Integer.toString(crit_mult),
+ Integer.toString(luck),Integer.toString(characterPortrait),Integer.toString(points),name};
+ MainActivity.player.writeToDB(tmp);
+ MainActivity.player.refresh();
+ freePoints.setText("Free points: "+points);
+ setButton.setVisibility(View.INVISIBLE);
+ }
+
+
+
+ public void agilityPlus(View view) {
+ if (pointTmp != 0 && agilityTmp < 100){
+ agilityTmp++;
+ playerAgility.setText("" + agilityTmp);
+ pointTmp--;
+ setButton.setVisibility(View.VISIBLE);
+ }
+ }
+
+ public void agilityMinus(View view) {
+ if (agilityTmp == agility){
+ } else {
+ agilityTmp --;
+ pointTmp++;
+ playerAgility.setText(""+agilityTmp);
+ if (pointTmp == points){
+ setButton.setVisibility(View.INVISIBLE);
+ }}
+ }
+
+ public void strengthPlus(View view) {
+ if (pointTmp != 0){
+ strengthTmp++;
+ playerStrenght.setText("" + strengthTmp);
+ pointTmp--;
+ setButton.setVisibility(View.VISIBLE);
+ }
+ }
+
+ public void strengthMinus(View view) {
+ if (strengthTmp == strenght){
+ } else {
+ strengthTmp --;
+ pointTmp++;
+ playerStrenght.setText(""+strengthTmp);
+ if (pointTmp == points){
+ setButton.setVisibility(View.INVISIBLE);
+ }}
+ }
+
+ public void critChancePlus(View view) {
+ if (pointTmp != 0 && critChanceTmp < 100){
+ critChanceTmp++;
+ playerCritChance.setText("" + critChanceTmp);
+ pointTmp--;
+ setButton.setVisibility(View.VISIBLE);
+ }
+ }
+
+ public void critChanceMinus(View view) {
+ if (critChanceTmp == crit_chance){
+ } else {
+ critChanceTmp --;
+ pointTmp++;
+ playerCritChance.setText(""+critChanceTmp);
+ if (pointTmp == points){
+ setButton.setVisibility(View.INVISIBLE);
+ }}
+ }
+
+
+ public void critMultPlus(View view) {
+ if (pointTmp != 0 ){
+ critMultTmp++;
+ playerCritMult.setText("" + critMultTmp);
+ pointTmp--;
+ setButton.setVisibility(View.VISIBLE);
+ }
+ }
+
+ public void critMultMinus(View view) {
+ if (critMultTmp == crit_mult){
+ } else {
+ critMultTmp --;
+ pointTmp++;
+ playerCritMult.setText(""+critMultTmp);
+ if (pointTmp == points){
+ setButton.setVisibility(View.INVISIBLE);
+ }}
+ }
+
+ public void luckPlus(View view) {
+ if (pointTmp != 0 && luckTmp < 100){
+ luckTmp++;
+ playerLuck.setText("" + luckTmp);
+ pointTmp--;
+ setButton.setVisibility(View.VISIBLE);
+ }
+ }
+
+ public void luckMinus(View view) {
+ if (luckTmp == luck){
+ } else {
+ luckTmp --;
+ pointTmp++;
+ playerLuck.setText(""+luckTmp);
+ if (pointTmp == points){
+ setButton.setVisibility(View.INVISIBLE);
+ }}
+ }
+
+}
diff --git a/app/src/main/java/com/example/denis/fightclub/MainActivity.java b/app/src/main/java/com/example/denis/fightclub/MainActivity.java
index 8c4319e..d5fd2d2 100644
--- a/app/src/main/java/com/example/denis/fightclub/MainActivity.java
+++ b/app/src/main/java/com/example/denis/fightclub/MainActivity.java
@@ -1,47 +1,68 @@
package com.example.denis.fightclub;
+import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
-import android.widget.Button;
+
+import com.example.denis.fightclub.entity.Player;
+
/**
* Created by Denis on 06.05.2016.
*/
public class MainActivity extends AppCompatActivity {
-
- private SharedPreferences session;
- public static final String Game_Session = "Session";
- public static final String Is_Game_End = "End";
- public static boolean isContinue;
- Button gameCont;
+ public static final String APP_PREFERENCES = "Settings";
+ public static final String RUN_ONCE = "run";
+ private SharedPreferences sharedPreferences;
+ static Player player;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
- gameCont = (Button) findViewById(R.id.continueGame);
- gameCont.setClickable(false);
- gameCont.setVisibility(View.INVISIBLE);
- session = getSharedPreferences(Game_Session,MODE_PRIVATE);
- if (session.getBoolean(Is_Game_End,false) == false){
- gameCont.setClickable(true);
- gameCont.setVisibility(View.VISIBLE);
+ sharedPreferences = getSharedPreferences(APP_PREFERENCES, Context.MODE_PRIVATE);
+ if (!(sharedPreferences.getBoolean(RUN_ONCE,false))){
+
+ SharedPreferences.Editor editor = sharedPreferences.edit();
+ editor.putBoolean(RUN_ONCE,true);
+ editor.apply();
}
+
+ player = new Player(this);
+ player.refresh();
+ fullscreen();
}
+ @Override
+ protected void onResume() {
+ super.onResume();
+ fullscreen();
+ }
+
public void newGame(View view) {
- isContinue = false;
Intent intent = new Intent(MainActivity.this, GameActivity.class);
+ player.newGame();
startActivity(intent);
}
- public void continueGame(View view) {
- isContinue = true;
- Intent intent = new Intent(MainActivity.this, GameActivity.class);
+ public void fullscreen(){
+ getWindow().getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_IMMERSIVE
+ );
+ }
+
+ public void Hero(View view) {
+ Intent intent = new Intent(MainActivity.this,HeroActivity.class);
startActivity(intent);
}
}
+
diff --git a/app/src/main/java/com/example/denis/fightclub/PortraitActivity.java b/app/src/main/java/com/example/denis/fightclub/PortraitActivity.java
new file mode 100644
index 0000000..ae93c05
--- /dev/null
+++ b/app/src/main/java/com/example/denis/fightclub/PortraitActivity.java
@@ -0,0 +1,216 @@
+package com.example.denis.fightclub;
+
+import android.content.Intent;
+import android.os.Bundle;
+import android.support.annotation.Nullable;
+import android.support.v7.app.AppCompatActivity;
+import android.view.View;
+
+
+/**
+ * Created by Denis on 11.05.2016.
+ */
+public class PortraitActivity extends AppCompatActivity {
+ public int character;
+
+
+ @Override
+ protected void onCreate(@Nullable Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_portrait);
+ fullscreen();
+ }
+
+ public void setPortrait(){
+ MainActivity.player.setPortrait(character);
+ Intent returnIntent = new Intent();
+ setResult(RESULT_OK,returnIntent);
+ super.onBackPressed();
+ }
+
+ public void fullscreen(){
+ getWindow().getDecorView().setSystemUiVisibility(
+ View.SYSTEM_UI_FLAG_LAYOUT_STABLE
+ | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
+ | View.SYSTEM_UI_FLAG_FULLSCREEN
+ | View.SYSTEM_UI_FLAG_IMMERSIVE
+ );
+ }
+
+ public void character1(View view) {
+ character = R.drawable.character1;
+ setPortrait();
+ }
+
+ public void character2(View view) {
+ character = R.drawable.character2;
+ setPortrait();
+ }
+
+ public void character3(View view) {
+ character = R.drawable.character3;
+ setPortrait();
+ }
+
+ public void character4(View view) {
+ character = R.drawable.character4;
+ setPortrait();
+ }
+
+ public void character5(View view) {
+ character = R.drawable.character5;
+ setPortrait();
+ }
+
+ public void character6(View view) {
+ character = R.drawable.character6;
+ setPortrait();
+ }
+
+ public void character7(View view) {
+ character = R.drawable.character7;
+ setPortrait();
+ }
+
+ public void character8(View view) {
+ character = R.drawable.character8;
+ setPortrait();
+ }
+
+ public void character9(View view) {
+ character = R.drawable.character9;
+ setPortrait();
+ }
+
+ public void character10(View view) {
+ character = R.drawable.character10;
+ setPortrait();
+ }
+
+ public void character11(View view) {
+ character = R.drawable.character11;
+ setPortrait();
+ }
+
+ public void character12(View view) {
+ character = R.drawable.character12;
+ setPortrait();
+ }
+
+ public void character13(View view) {
+ character = R.drawable.character13;
+ setPortrait();
+ }
+
+ public void character14(View view) {
+ character = R.drawable.character14;
+ setPortrait();
+ }
+
+ public void character15(View view) {
+ character = R.drawable.character15;
+ setPortrait();
+ }
+
+ public void character16(View view) {
+ character = R.drawable.character16;
+ setPortrait();
+ }
+
+ public void character17(View view) {
+ character = R.drawable.character17;
+ setPortrait();
+ }
+
+ public void character18(View view) {
+ character = R.drawable.character18;
+ setPortrait();
+ }
+
+ public void character19(View view) {
+ character = R.drawable.character19;
+ setPortrait();
+ }
+
+ public void character20(View view) {
+ character = R.drawable.character20;
+ setPortrait();
+ }
+
+ public void character21(View view) {
+ character = R.drawable.character21;
+ setPortrait();
+ }
+
+ public void character22(View view) {
+ character = R.drawable.character22;
+ setPortrait();
+ }
+
+ public void character23(View view) {
+ character = R.drawable.character23;
+ setPortrait();
+ }
+
+ public void character24(View view) {
+ character = R.drawable.character24;
+ setPortrait();
+ }
+
+ public void character25(View view) {
+ character = R.drawable.character25;
+ setPortrait();
+ }
+
+ public void character26(View view) {
+ character = R.drawable.character26;
+ setPortrait();
+ }
+
+ public void character27(View view) {
+ character = R.drawable.character27;
+ setPortrait();
+ }
+
+ public void character28(View view) {
+ character = R.drawable.character28;
+ setPortrait();
+ }
+
+ public void character29(View view) {
+ character = R.drawable.character29;
+ setPortrait();
+ }
+
+ public void character30(View view) {
+ character = R.drawable.character30;
+ setPortrait();
+ }
+
+ public void character31(View view) {
+ character = R.drawable.character31;
+ setPortrait();
+ }
+
+ public void character32(View view) {
+ character = R.drawable.character32;
+ setPortrait();
+ }
+
+ public void character33(View view) {
+ character = R.drawable.character33;
+ setPortrait();
+ }
+
+ public void character34(View view) {
+ character = R.drawable.character34;
+ setPortrait();
+ }
+
+ public void character35(View view) {
+ character = R.drawable.character35;
+ setPortrait();
+ }
+}
diff --git a/app/src/main/java/com/example/denis/fightclub/entity/Enemy.java b/app/src/main/java/com/example/denis/fightclub/entity/Enemy.java
new file mode 100644
index 0000000..b966a78
--- /dev/null
+++ b/app/src/main/java/com/example/denis/fightclub/entity/Enemy.java
@@ -0,0 +1,150 @@
+package com.example.denis.fightclub.entity;
+
+import android.content.Context;
+import android.content.res.Resources;
+
+import com.example.denis.fightclub.MainActivity;
+import com.example.denis.fightclub.R;
+
+import java.util.Random;
+
+/**
+ * Created by Denis on 10.05.2016.
+ */
+public class Enemy {
+ private int health;
+ private int attack;
+ private int defence;
+ private int attackVector;
+ private int defenceVector;
+ private int strength;
+ private int agility;
+ private int critMult;
+ private int critChance;
+ private int portrait;
+
+ public int getMaxHealth() {
+ return maxHealth;
+ }
+
+ private int maxHealth;
+
+ final Random random = new Random();
+
+ public Enemy(int playerPoints){
+ for (int i = 0; i < playerPoints; i++){
+ switch (random.nextInt(4)){
+ case 0: ++strength; break;
+ case 1: if (agility < 100){++agility;} break;
+ case 2: ++ critMult; break;
+ case 3: if (critChance < 100){++critChance;} break;
+ }
+ }
+ maxHealth = (100 + (50 * strength));
+ health = maxHealth;
+ portrait();
+ }
+
+ public int getHealth() {
+ return health;
+ }
+
+
+ private int getAttack() {
+ attack = random.nextInt(10) + 1;
+ return attack;
+ }
+
+ public int doDamage() {
+ int damage = getAttack();
+ if (critChance() == true){
+ damage = (int) (getAttack() * (1.5 + (0.5 * critMult)));
+ }
+ return damage;
+ }
+
+ public void takeDamage(int playerDamage, int playerAttackeVector) {
+ defenceVector = random.nextInt(4) + 1;
+ boolean tmp = evesion();
+ if (tmp != true){
+ if (playerAttackeVector == defenceVector){
+ health = health -(playerDamage - getDefence());
+ }else {
+ health = health - playerDamage;}}
+ }
+
+ private int getDefence() {
+ defence = random.nextInt(5) + 1;
+ return defence;
+ }
+
+ public int getAttackVector() {
+ attackVector = random.nextInt(10) + 1;
+ return attackVector;
+ }
+
+ private boolean critChance(){
+ boolean crit = false;
+ if (1 == (random.nextInt(1001 - (10 * critChance))) + 1){
+ crit = true;
+ }
+ return crit;
+ }
+
+ private boolean evesion(){
+ boolean evesion = false;
+ if (1 == (random.nextInt(1001 - (10 * agility))) + 1){
+ evesion = true;
+ }
+ return evesion;
+ }
+
+ private void portrait(){
+ switch (random.nextInt(35)){
+ case 0: portrait = R.drawable.character1; break;
+ case 1: portrait = R.drawable.character2; break;
+ case 2: portrait = R.drawable.character3; break;
+ case 3: portrait = R.drawable.character4; break;
+ case 4: portrait = R.drawable.character5; break;
+ case 5: portrait = R.drawable.character6; break;
+ case 6: portrait = R.drawable.character7; break;
+ case 7: portrait = R.drawable.character8; break;
+ case 8: portrait = R.drawable.character9; break;
+ case 9: portrait = R.drawable.character10; break;
+ case 10: portrait = R.drawable.character11; break;
+ case 11: portrait = R.drawable.character12; break;
+ case 12: portrait = R.drawable.character13; break;
+ case 13: portrait = R.drawable.character14; break;
+ case 14: portrait = R.drawable.character15; break;
+ case 15: portrait = R.drawable.character16; break;
+ case 16: portrait = R.drawable.character17; break;
+ case 17: portrait = R.drawable.character18; break;
+ case 18: portrait = R.drawable.character19; break;
+ case 19: portrait = R.drawable.character20; break;
+ case 20: portrait = R.drawable.character21; break;
+ case 21: portrait = R.drawable.character22; break;
+ case 22: portrait = R.drawable.character23; break;
+ case 23: portrait = R.drawable.character24; break;
+ case 24: portrait = R.drawable.character25; break;
+ case 25: portrait = R.drawable.character26; break;
+ case 26: portrait = R.drawable.character27; break;
+ case 27: portrait = R.drawable.character28; break;
+ case 28: portrait = R.drawable.character29; break;
+ case 29: portrait = R.drawable.character30; break;
+ case 30: portrait = R.drawable.character31; break;
+ case 31: portrait = R.drawable.character32; break;
+ case 32: portrait = R.drawable.character33; break;
+ case 33: portrait = R.drawable.character34; break;
+ case 34: portrait = R.drawable.character35; break;
+ }
+ }
+
+ public int getPortrait() {
+ return portrait;
+ }
+
+ public String getName(Context context){
+ String[] name = context.getResources().getStringArray(R.array.enemy);
+ return name[random.nextInt(name.length)];
+ }
+}
diff --git a/app/src/main/java/com/example/denis/fightclub/entity/Player.java b/app/src/main/java/com/example/denis/fightclub/entity/Player.java
new file mode 100644
index 0000000..cacd9e5
--- /dev/null
+++ b/app/src/main/java/com/example/denis/fightclub/entity/Player.java
@@ -0,0 +1,232 @@
+package com.example.denis.fightclub.entity;
+
+import android.content.Context;
+import android.content.Intent;
+
+import com.example.denis.fightclub.util.DBManipulator;
+
+import java.util.Random;
+
+/**
+ * Created by Denis on 09.05.2016.
+ */
+public class Player {
+
+ private int currentHealth;
+ private int attack;
+ private int defence;
+ private int attackVector = 0;
+ private int defenceVector = 0;
+ private int strength;
+ private int agility;
+ private int critMult;
+ private int critChance;
+ private int luck;
+ private int maxHealth;
+ private int portrait;
+ private int points;
+ private String name;
+
+ final Random random = new Random();
+ DBManipulator dbManipulator;
+
+ public Player(Context context){
+ dbManipulator = new DBManipulator(context);
+ }
+
+ public void newGame(){
+ setCurrentHealth(maxHealth);
+ }
+
+ public int getCurrentHealth() {
+ return currentHealth;
+ }
+
+ public void setCurrentHealth(int currentHealth) {
+ this.currentHealth = currentHealth;
+ }
+
+ public int getMaxHealth() {
+ return maxHealth;
+ }
+
+ private int getAttack() {
+ attack = random.nextInt(10) + 1;
+ return attack;
+ }
+
+ public int doDamage (){
+ int damage = getAttack();
+ if (critChance() == true){
+ damage = (int) (getAttack() * (1.5 + (0.5 * getCritMult())));
+ }
+ return damage;
+ }
+
+ public void takeDamage (int enemeDamage, int enemyAttackeVector){
+ boolean tmp = evesion();
+ if (tmp != true){
+ if (enemyAttackeVector == defenceVector){
+ currentHealth = currentHealth -(enemeDamage - getDefence());
+ }else {
+ currentHealth = currentHealth - enemeDamage;}}
+ }
+
+ public int getDefence() {
+ defence = random.nextInt(5) + 1;
+ return defence;
+ }
+
+ public void setAttackVector(int attackVector) {
+ this.attackVector = attackVector;
+ }
+
+ public void setDefenceVector(int defenceVector) {
+ this.defenceVector = defenceVector;
+ }
+
+ public int getAttackVector() {
+ return attackVector;
+ }
+
+ public int getStrength() {
+ return strength;
+ }
+
+ public void setStrength(int strength) {
+ this.strength = strength;
+ }
+
+ public int getAgility() {
+ return agility;
+ }
+
+ public void setAgility(int agility) {
+ this.agility = agility;
+ }
+
+ public int getCritChance() {
+ return critChance;
+ }
+
+ public void setCritChance(int critChance) {
+ dbManipulator.setCritChance(critChance);
+ this.critChance = critChance;
+ }
+
+ public int getLuck() {
+ return luck;
+ }
+
+ public void setLuck(int luck) {
+ dbManipulator.setLuck(luck);
+ this.luck = luck;
+ }
+
+
+ public int getPortrait() {
+ return portrait;
+ }
+
+ public void setPortrait(int portrait) {
+ dbManipulator.setCharacterPortrait(portrait);
+ this.portrait = portrait;
+ }
+
+ public void refresh(){
+ int[] s;
+ s = dbManipulator.getAll();
+ strength = s[0];
+ agility = s[1];
+ critMult = s[2];
+ critChance = s[3];
+ luck = s[4];
+ portrait = s[5];
+ points = s[6];
+ name = dbManipulator.getName();
+ maxHealth = 100 + (strength * 50);
+ }
+
+ public int getCritMult() {
+ return critMult;
+ }
+
+ public void setCritMult(int critMult) {
+ dbManipulator.setCritChance(critMult);
+ this.critMult = critMult;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ dbManipulator.setName(name);
+ this.name = name;
+ }
+
+ private boolean evesion(){
+ boolean evesion = false;
+ if (1 == (random.nextInt(1001 - (10 * agility))) + 1){
+ evesion = true;
+ }
+ return evesion;
+ }
+
+
+
+ private boolean critChance(){
+ boolean crit = false;
+ if (1 == (random.nextInt(1001 - (10 * critChance))) + 1){
+ crit = true;
+ }
+ return crit;
+ }
+
+ public boolean isYouLucky(){
+ if (1 == (random.nextInt(1001 - (10 * luck))) + 1){
+ setPoints(points + 1);
+ return true;
+ }else{
+ return false;}
+ }
+
+ public int getPoints() {
+ return points;
+ }
+
+ public void setPoints(int points) {
+ dbManipulator.setPoint(points);
+ this.points = points;
+ }
+
+ public String[] getAll(){
+ String[] all = new String[8];
+ all[0] = Integer.toString(strength);
+ all[1] = Integer.toString(agility);
+ all[2] = Integer.toString(critChance);
+ all[3] = Integer.toString(critMult);
+ all[4] = Integer.toString(luck);
+ all[5] = Integer.toString(portrait);
+ all[6] = Integer.toString(points);
+ all[7] = name;
+ return all;
+ }
+
+ public void writeToDB(String[] all){
+ dbManipulator.setStrenght(Integer.parseInt(all[0]));
+ dbManipulator.setAgility(Integer.parseInt(all[1]));
+ dbManipulator.setCritChance(Integer.parseInt(all[2]));
+ dbManipulator.setCritMult(Integer.parseInt(all[3]));
+ dbManipulator.setLuck(Integer.parseInt(all[4]));
+ dbManipulator.setCharacterPortrait(Integer.parseInt(all[5]));
+ dbManipulator.setPoint(Integer.parseInt(all[6]));
+ dbManipulator.setName(name);
+ }
+
+ public int numberOfPoints(){
+ int tmp;
+ tmp = strength + agility + critChance + critMult + luck;
+ return tmp;
+ }
+}
diff --git a/app/src/main/java/com/example/denis/fightclub/util/DBManipulator.java b/app/src/main/java/com/example/denis/fightclub/util/DBManipulator.java
new file mode 100644
index 0000000..55e00b5
--- /dev/null
+++ b/app/src/main/java/com/example/denis/fightclub/util/DBManipulator.java
@@ -0,0 +1,150 @@
+package com.example.denis.fightclub.util;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.Cursor;
+import android.database.sqlite.SQLiteDatabase;
+
+/**
+ * Created by Denis on 10.05.2016.
+ */
+public class DBManipulator {
+
+ public SQLiteDatabase sqLiteDatabase;
+ public DatabaseHelper databaseHelper;
+ public ContentValues contentValues = new ContentValues();
+
+ public DBManipulator(Context context){
+ databaseHelper = new DatabaseHelper(context, "player.db", null, 1);
+ sqLiteDatabase = databaseHelper.getReadableDatabase();
+
+ }
+
+ public int[] getAll(){
+ int[] s = new int[7];
+ Cursor cursor = sqLiteDatabase.query("player",new String[]{DatabaseHelper.PLAYER_STRENGHT,DatabaseHelper.PLAYER_AGILITY,DatabaseHelper.PLAYER_CRIT_MULT,
+ DatabaseHelper.PLAYER_CRIT_CHANCE,DatabaseHelper.PLAYER_LUCK,DatabaseHelper.PLAYER_PORTRAIT,DatabaseHelper.PLAYER_POINTS},null,null,null,null,null);
+ cursor.moveToFirst();
+ s [0] = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_STRENGHT));
+ s [1] = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_AGILITY));
+ s [2] = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_CRIT_MULT));
+ s [3] = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_CRIT_CHANCE));
+ s [4] = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_LUCK));
+ s [5] = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_PORTRAIT));
+ s [6] = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_POINTS));
+ cursor.close();
+ return s;
+ }
+
+ public String getName(){
+ String name;
+ Cursor cursor = sqLiteDatabase.query("player",new String[]{DatabaseHelper.PLAYER_NAME_COLUMN},null,null,null,null,null);
+ cursor.moveToFirst();
+ name = cursor.getString(cursor.getColumnIndex(DatabaseHelper.PLAYER_NAME_COLUMN));
+ cursor.close();
+ return name;
+ }
+
+ public void setName(String name){
+ contentValues.put(DatabaseHelper.PLAYER_NAME_COLUMN,name);
+ sqLiteDatabase.update("player",contentValues,DatabaseHelper.PLAYER_NAME_COLUMN + "<> ?", new String[]{"null"});
+ }
+
+ public int getStrenght(){
+ int strenght;
+ Cursor cursor = sqLiteDatabase.query("player",new String[]{DatabaseHelper.PLAYER_STRENGHT},null,null,null,null,null);
+ cursor.moveToFirst();
+ strenght = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_STRENGHT));
+ cursor.close();
+ return strenght;
+ }
+
+ public void setStrenght(int strenght){
+ contentValues.put(DatabaseHelper.PLAYER_STRENGHT,strenght);
+ sqLiteDatabase.update("player",contentValues,DatabaseHelper.PLAYER_STRENGHT + "<> ?", new String[]{"null"});
+ }
+
+ public int getAgility(){
+ int agility;
+ Cursor cursor = sqLiteDatabase.query("player",new String[]{DatabaseHelper.PLAYER_AGILITY},null,null,null,null,null);
+ cursor.moveToFirst();
+ agility = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_AGILITY));
+ cursor.close();
+ return agility;
+ }
+
+ public void setAgility(int agility){
+ contentValues.put(DatabaseHelper.PLAYER_AGILITY,agility);
+ sqLiteDatabase.update("player",contentValues,DatabaseHelper.PLAYER_AGILITY + "<> ?", new String[]{"null"});
+ }
+
+ public int getCritChance(){
+ int critChance;
+ Cursor cursor = sqLiteDatabase.query("player",new String[]{DatabaseHelper.PLAYER_CRIT_CHANCE},null,null,null,null,null);
+ cursor.moveToFirst();
+ critChance = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_CRIT_CHANCE));
+ cursor.close();
+ return critChance;
+ }
+
+ public void setCritChance(int critChance){
+ contentValues.put(DatabaseHelper.PLAYER_CRIT_CHANCE,critChance);
+ sqLiteDatabase.update("player",contentValues,DatabaseHelper.PLAYER_CRIT_CHANCE + "<> ?", new String[]{"null"});
+ }
+
+ public int getCritMult(){
+ int critMult;
+ Cursor cursor = sqLiteDatabase.query("player",new String[]{DatabaseHelper.PLAYER_CRIT_MULT},null,null,null,null,null);
+ cursor.moveToFirst();
+ critMult = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_CRIT_MULT));
+ cursor.close();
+ return critMult;
+ }
+
+ public void setCritMult(int critMult){
+ contentValues.put(DatabaseHelper.PLAYER_CRIT_CHANCE,critMult);
+ sqLiteDatabase.update("player",contentValues,DatabaseHelper.PLAYER_CRIT_MULT + "<> ?", new String[]{"null"});
+ }
+
+ public int getLuck(){
+ int luck;
+ Cursor cursor = sqLiteDatabase.query("player",new String[]{DatabaseHelper.PLAYER_LUCK},null,null,null,null,null);
+ cursor.moveToFirst();
+ luck = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_LUCK));
+ cursor.close();
+ return luck;
+ }
+
+ public void setLuck(int luck){
+ contentValues.put(DatabaseHelper.PLAYER_LUCK,luck);
+ sqLiteDatabase.update("player",contentValues,DatabaseHelper.PLAYER_LUCK + "<> ?", new String[]{"null"});
+ }
+
+ public int getCharacterPortrait(){
+ int portrait;
+ Cursor cursor = sqLiteDatabase.query("player",new String[]{DatabaseHelper.PLAYER_PORTRAIT},null,null,null,null,null);
+ cursor.moveToFirst();
+ portrait = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_PORTRAIT));
+ cursor.close();
+ return portrait;
+ }
+
+ public void setCharacterPortrait(int portrait){
+ contentValues.put(DatabaseHelper.PLAYER_PORTRAIT,portrait);
+ sqLiteDatabase.update("player",contentValues,DatabaseHelper.PLAYER_PORTRAIT + "<> ?", new String[]{"null"});
+ }
+
+ public void setPoint(int point){
+ contentValues.put(DatabaseHelper.PLAYER_POINTS,point);
+ sqLiteDatabase.update("player",contentValues,DatabaseHelper.PLAYER_POINTS + "<> ?", new String[]{"null"});
+ }
+
+ public int getPoints(){
+ int points;
+ Cursor cursor = sqLiteDatabase.query("player",new String[]{databaseHelper.PLAYER_POINTS},null,null,null,null,null);
+ cursor.moveToFirst();
+ points = cursor.getInt(cursor.getColumnIndex(DatabaseHelper.PLAYER_POINTS));
+ cursor.close();
+ return points;
+ }
+}
diff --git a/app/src/main/java/com/example/denis/fightclub/util/DatabaseHelper.java b/app/src/main/java/com/example/denis/fightclub/util/DatabaseHelper.java
new file mode 100644
index 0000000..d7873d1
--- /dev/null
+++ b/app/src/main/java/com/example/denis/fightclub/util/DatabaseHelper.java
@@ -0,0 +1,68 @@
+package com.example.denis.fightclub.util;
+
+import android.content.ContentValues;
+import android.content.Context;
+import android.database.DatabaseErrorHandler;
+import android.database.sqlite.SQLiteDatabase;
+import android.database.sqlite.SQLiteOpenHelper;
+import android.provider.BaseColumns;
+
+import com.example.denis.fightclub.R;
+
+/**
+ * Created by Denis on 10.05.2016.
+ */
+public class DatabaseHelper extends SQLiteOpenHelper {
+ private static final String DATABASE_NAME = "player.db";
+ private static final int DATABASE_VERSION = 2;
+ private static final String DATABASE_TABLE = "player";
+
+ public static final String PLAYER_NAME_COLUMN = "player_name";
+ public static final String PLAYER_STRENGHT = "strenght";
+ public static final String PLAYER_AGILITY = "agility";
+ public static final String PLAYER_CRIT_CHANCE = "crit_chance";
+ public static final String PLAYER_CRIT_MULT = "crit_multipl";
+ public static final String PLAYER_LUCK = "luck";
+ public static final String PLAYER_PORTRAIT = "portrait";
+ public static final String PLAYER_POINTS = "points";
+
+
+ private static final String DATABASE_CREATE = "create table "
+ + DATABASE_TABLE + " (" + BaseColumns._ID
+ + " integer primary key autoincrement, " + PLAYER_NAME_COLUMN
+ + " text not null, " + PLAYER_STRENGHT + " integer, " + PLAYER_AGILITY
+ + " integer, " + PLAYER_CRIT_CHANCE + " integer, " + PLAYER_CRIT_MULT
+ + " integer, " + PLAYER_LUCK + " integer, " + PLAYER_PORTRAIT + " integer, " + PLAYER_POINTS + " integer);";
+
+ public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version, DatabaseErrorHandler errorHandler) {
+ super(context, name, factory, version, errorHandler);
+ }
+
+ public DatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
+ super(context, name, factory, version);
+ }
+
+ DatabaseHelper (Context context){
+ super(context, DATABASE_NAME , null, DATABASE_VERSION);
+ }
+
+ @Override
+ public void onCreate(SQLiteDatabase db) {
+ db.execSQL(DATABASE_CREATE);
+ ContentValues values = new ContentValues();
+ values.put(PLAYER_NAME_COLUMN,"Player");
+ values.put(PLAYER_STRENGHT,0);
+ values.put(PLAYER_AGILITY,0);
+ values.put(PLAYER_CRIT_CHANCE,0);
+ values.put(PLAYER_CRIT_MULT,0);
+ values.put(PLAYER_LUCK,0);
+ values.put(PLAYER_POINTS,0);
+ values.put(PLAYER_PORTRAIT, R.drawable.character1);
+ db.insert("player",null,values);
+ }
+
+ @Override
+ public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
+
+ }
+}
diff --git a/app/src/main/res/drawable/background.png b/app/src/main/res/drawable/background.png
new file mode 100644
index 0000000..583b7b8
Binary files /dev/null and b/app/src/main/res/drawable/background.png differ
diff --git a/app/src/main/res/drawable/character1.png b/app/src/main/res/drawable/character1.png
new file mode 100644
index 0000000..6c3b6a0
Binary files /dev/null and b/app/src/main/res/drawable/character1.png differ
diff --git a/app/src/main/res/drawable/character10.png b/app/src/main/res/drawable/character10.png
new file mode 100644
index 0000000..adc6fd5
Binary files /dev/null and b/app/src/main/res/drawable/character10.png differ
diff --git a/app/src/main/res/drawable/character11.png b/app/src/main/res/drawable/character11.png
new file mode 100644
index 0000000..ee76ae8
Binary files /dev/null and b/app/src/main/res/drawable/character11.png differ
diff --git a/app/src/main/res/drawable/character12.png b/app/src/main/res/drawable/character12.png
new file mode 100644
index 0000000..0ce8f54
Binary files /dev/null and b/app/src/main/res/drawable/character12.png differ
diff --git a/app/src/main/res/drawable/character13.png b/app/src/main/res/drawable/character13.png
new file mode 100644
index 0000000..b93ac13
Binary files /dev/null and b/app/src/main/res/drawable/character13.png differ
diff --git a/app/src/main/res/drawable/character14.png b/app/src/main/res/drawable/character14.png
new file mode 100644
index 0000000..885a928
Binary files /dev/null and b/app/src/main/res/drawable/character14.png differ
diff --git a/app/src/main/res/drawable/character15.png b/app/src/main/res/drawable/character15.png
new file mode 100644
index 0000000..7ca5be2
Binary files /dev/null and b/app/src/main/res/drawable/character15.png differ
diff --git a/app/src/main/res/drawable/character16.png b/app/src/main/res/drawable/character16.png
new file mode 100644
index 0000000..5cd8d76
Binary files /dev/null and b/app/src/main/res/drawable/character16.png differ
diff --git a/app/src/main/res/drawable/character17.png b/app/src/main/res/drawable/character17.png
new file mode 100644
index 0000000..8545d82
Binary files /dev/null and b/app/src/main/res/drawable/character17.png differ
diff --git a/app/src/main/res/drawable/character18.png b/app/src/main/res/drawable/character18.png
new file mode 100644
index 0000000..d543683
Binary files /dev/null and b/app/src/main/res/drawable/character18.png differ
diff --git a/app/src/main/res/drawable/character19.png b/app/src/main/res/drawable/character19.png
new file mode 100644
index 0000000..7968124
Binary files /dev/null and b/app/src/main/res/drawable/character19.png differ
diff --git a/app/src/main/res/drawable/character2.png b/app/src/main/res/drawable/character2.png
new file mode 100644
index 0000000..36018be
Binary files /dev/null and b/app/src/main/res/drawable/character2.png differ
diff --git a/app/src/main/res/drawable/character20.png b/app/src/main/res/drawable/character20.png
new file mode 100644
index 0000000..a78bd59
Binary files /dev/null and b/app/src/main/res/drawable/character20.png differ
diff --git a/app/src/main/res/drawable/character21.png b/app/src/main/res/drawable/character21.png
new file mode 100644
index 0000000..a20390e
Binary files /dev/null and b/app/src/main/res/drawable/character21.png differ
diff --git a/app/src/main/res/drawable/character22.png b/app/src/main/res/drawable/character22.png
new file mode 100644
index 0000000..f0b7b6b
Binary files /dev/null and b/app/src/main/res/drawable/character22.png differ
diff --git a/app/src/main/res/drawable/character23.png b/app/src/main/res/drawable/character23.png
new file mode 100644
index 0000000..250c690
Binary files /dev/null and b/app/src/main/res/drawable/character23.png differ
diff --git a/app/src/main/res/drawable/character24.png b/app/src/main/res/drawable/character24.png
new file mode 100644
index 0000000..78a621a
Binary files /dev/null and b/app/src/main/res/drawable/character24.png differ
diff --git a/app/src/main/res/drawable/character25.png b/app/src/main/res/drawable/character25.png
new file mode 100644
index 0000000..6906236
Binary files /dev/null and b/app/src/main/res/drawable/character25.png differ
diff --git a/app/src/main/res/drawable/character26.png b/app/src/main/res/drawable/character26.png
new file mode 100644
index 0000000..a4fd3ad
Binary files /dev/null and b/app/src/main/res/drawable/character26.png differ
diff --git a/app/src/main/res/drawable/character27.png b/app/src/main/res/drawable/character27.png
new file mode 100644
index 0000000..34563a5
Binary files /dev/null and b/app/src/main/res/drawable/character27.png differ
diff --git a/app/src/main/res/drawable/character28.png b/app/src/main/res/drawable/character28.png
new file mode 100644
index 0000000..737d9f4
Binary files /dev/null and b/app/src/main/res/drawable/character28.png differ
diff --git a/app/src/main/res/drawable/character29.png b/app/src/main/res/drawable/character29.png
new file mode 100644
index 0000000..f22d94b
Binary files /dev/null and b/app/src/main/res/drawable/character29.png differ
diff --git a/app/src/main/res/drawable/character3.png b/app/src/main/res/drawable/character3.png
new file mode 100644
index 0000000..8079e7b
Binary files /dev/null and b/app/src/main/res/drawable/character3.png differ
diff --git a/app/src/main/res/drawable/character30.png b/app/src/main/res/drawable/character30.png
new file mode 100644
index 0000000..74a0f2c
Binary files /dev/null and b/app/src/main/res/drawable/character30.png differ
diff --git a/app/src/main/res/drawable/character31.png b/app/src/main/res/drawable/character31.png
new file mode 100644
index 0000000..d782ad7
Binary files /dev/null and b/app/src/main/res/drawable/character31.png differ
diff --git a/app/src/main/res/drawable/character32.png b/app/src/main/res/drawable/character32.png
new file mode 100644
index 0000000..d31ed08
Binary files /dev/null and b/app/src/main/res/drawable/character32.png differ
diff --git a/app/src/main/res/drawable/character33.png b/app/src/main/res/drawable/character33.png
new file mode 100644
index 0000000..3889dfa
Binary files /dev/null and b/app/src/main/res/drawable/character33.png differ
diff --git a/app/src/main/res/drawable/character34.png b/app/src/main/res/drawable/character34.png
new file mode 100644
index 0000000..1f82f86
Binary files /dev/null and b/app/src/main/res/drawable/character34.png differ
diff --git a/app/src/main/res/drawable/character35.png b/app/src/main/res/drawable/character35.png
new file mode 100644
index 0000000..1ce9d7a
Binary files /dev/null and b/app/src/main/res/drawable/character35.png differ
diff --git a/app/src/main/res/drawable/character4.png b/app/src/main/res/drawable/character4.png
new file mode 100644
index 0000000..4c4cd9f
Binary files /dev/null and b/app/src/main/res/drawable/character4.png differ
diff --git a/app/src/main/res/drawable/character5.png b/app/src/main/res/drawable/character5.png
new file mode 100644
index 0000000..05e6a9f
Binary files /dev/null and b/app/src/main/res/drawable/character5.png differ
diff --git a/app/src/main/res/drawable/character6.png b/app/src/main/res/drawable/character6.png
new file mode 100644
index 0000000..ce609e9
Binary files /dev/null and b/app/src/main/res/drawable/character6.png differ
diff --git a/app/src/main/res/drawable/character7.png b/app/src/main/res/drawable/character7.png
new file mode 100644
index 0000000..3234902
Binary files /dev/null and b/app/src/main/res/drawable/character7.png differ
diff --git a/app/src/main/res/drawable/character8.png b/app/src/main/res/drawable/character8.png
new file mode 100644
index 0000000..2ce7c03
Binary files /dev/null and b/app/src/main/res/drawable/character8.png differ
diff --git a/app/src/main/res/drawable/character9.png b/app/src/main/res/drawable/character9.png
new file mode 100644
index 0000000..7e329a6
Binary files /dev/null and b/app/src/main/res/drawable/character9.png differ
diff --git a/app/src/main/res/drawable/healthbar.xml b/app/src/main/res/drawable/healthbar.xml
new file mode 100644
index 0000000..51e6a51
--- /dev/null
+++ b/app/src/main/res/drawable/healthbar.xml
@@ -0,0 +1,29 @@
+
+
+
+ -
+
+
+
+
+
+ -
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_game.xml b/app/src/main/res/layout/activity_game.xml
index ef67ca1..92b9a0d 100644
--- a/app/src/main/res/layout/activity_game.xml
+++ b/app/src/main/res/layout/activity_game.xml
@@ -4,13 +4,13 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".GameActivity"
- android:background="@android:color/holo_green_dark">
+ android:background="@drawable/background">
@@ -18,7 +18,7 @@
@@ -28,87 +28,87 @@
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:id="@+id/playerRadio"
- android:layout_toEndOf="@+id/playerCharacter">
-
-
-
-
-
-
-
+ android:layout_toEndOf="@+id/playerPortrait">
+
+
+
+
+
+
+
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+ android:progressTint="#25f40a" />
+ android:textColor="#000000"
+ android:layout_alignStart="@+id/enemyHealthBar" />
-
-
-
-
-
-
-
+ android:textAppearance="?android:attr/textAppearanceMedium"
+ android:text="Player"
+ android:id="@+id/playerName"
+ android:layout_above="@+id/playerHealthBar"
+ android:layout_alignParentStart="true" />
+
+
diff --git a/app/src/main/res/layout/activity_hero.xml b/app/src/main/res/layout/activity_hero.xml
new file mode 100644
index 0000000..0664269
--- /dev/null
+++ b/app/src/main/res/layout/activity_hero.xml
@@ -0,0 +1,282 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index a1db6cc..55ef3e3 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -4,7 +4,8 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
- android:background="@android:color/holo_green_dark">
+ android:id="@+id/mainLayout"
+ android:background="@drawable/background">
-
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_portrait.xml b/app/src/main/res/layout/activity_portrait.xml
new file mode 100644
index 0000000..c4d7d73
--- /dev/null
+++ b/app/src/main/res/layout/activity_portrait.xml
@@ -0,0 +1,344 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
index cde69bc..8cec43a 100644
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
index c133a0c..82ed26f 100644
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
index bfa42f0..1fbec7b 100644
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
index 324e72c..5176226 100644
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
index aee44e1..ebe7a74 100644
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/app/src/main/res/values/enemy_names.xml b/app/src/main/res/values/enemy_names.xml
new file mode 100644
index 0000000..57be8d7
--- /dev/null
+++ b/app/src/main/res/values/enemy_names.xml
@@ -0,0 +1,86 @@
+
+
+
+ - Miralemas
+ - Ybirelind
+ - Direlin
+ - Tendan
+ - Asacien
+ - Rilanwan
+ - Deicia
+ - Edaohar
+ - Araumma
+ - Hikath
+ - Sevoalind
+ - Doasean
+ - Vithiel
+ - Jaliwin
+ - Chendathien
+ - Agrires
+ - Rhialla
+ - Aeldan
+ - Umiraweth
+ - Umelia
+ - Nydawen
+ - Cadiedric
+ - Rieweth
+ - Ibelalin
+ - Ulaeveth
+ - Cadayld
+ - Thiacia
+ - Thedridan
+ - Caolind
+ - Sevenyth
+ - Sanna
+ - Asterired
+ - Ethaniel
+ - Adrardosh
+ - Edaleng
+ - Bros
+ - Qiarien
+ - Ulardotrem
+ - Priracia
+ - Adiatha
+ - Galirarwen
+ - Cilalin
+ - Acoedien
+ - Jerraa
+ - Erywen
+ - Crybwyn
+ - Fraywen
+ - Uliebard
+ - Crardodda
+ - Umomaldan
+ - Tun
+ - Ethilaloth
+ - Freras
+ - Chaossa
+ - Eoweraseth
+ - Groidda
+ - Ibaotrem
+ - Lothymwen
+ - Eligot
+ - Frendaria
+ - Rheilith
+ - Theralle
+ - Celak
+ - Vauria
+ - Agrarerd
+ - Ralendra
+ - Eliatlan
+ - Dwerrang
+ - Wyg
+ - Adruweth
+ - Chaesean
+ - Codda
+ - Sean
+ - Umigocien
+ - Gerilin
+ - Kedieng
+ - Lothubard
+ - Haoithiel
+ - Jialath
+ - Wicaydia
+
+
+
\ No newline at end of file