<commit_before>﻿using UnityEngine;
using UnityEngine.SceneManagement;
using System.Collections;

public class Player : MonoBehaviour {

	private float healthPoint = 10f;
	private float magicPoint = 10f;

	private bool gameStarted = false;  // once network connected, set to true
	private bool singlePlayer = false;

	// Use this for initialization
	void Start () {
		// set single player and gamestarted to true if on single player mode
	}
	
	// Update is called once per frame
	void Update () {
		// single player mode
		if (singlePlayer) {
			if (healthPoint <= 0) {
				SceneManager.LoadScene (0);
				//Application.loadedLevel(null);
				Destroy (gameObject);
			}
		} 
		// multiplayer mode
		else {
			if (gameStarted) {
				if (healthPoint <= 0) {
					gameStarted = false;

					//network code here
					SceneManager.LoadScene(0);
					//Application.LoadLevel ();
					Destroy (gameObject);
				}
			} else {
				SceneManager.LoadScene (0);
				//Application.LoadLevel (null);
				Destroy (gameObject);
			}
		}
	}

	// subtract health from spell damage (call by Spell)
	public void ReduceHealth(float damage) {
		healthPoint -= damage;
	}

	// decrease mp from spell cost
	public void ReduceMagic(float mp) {
		magicPoint -= mp;
	}

	// increase magic from orbs (call by Orb)
	public void GainMP(float mp) {
		magicPoint += mp;
	}<commit_msg>Player model done, trying to figure out testing for it<commit_after>﻿using HoloToolkit.Unity;

public class Player : Singleton<Player> {

    private int MAX_HEALTH = 100;
    private int MAX_MAGIC = 10;

    // Looks like these are no longer needed. Review with team.
    //private bool gameStarted = false;  
    //private bool singlePlayer = false;

    private int health;
    private int magic;
	
    // Instantiates an object of type Player.
    // This is the data model that represents the current state of a player
    // within the game world. It tracks the health and magic points of the
    // player and reports those as requested to the appropriate game objects.
    // Representation invariant: A player must always have 0 < health <= 100
    //                           A player must always have 0 <= magic <= 10
	void Start ()
    {
        health = MAX_HEALTH;
        magic = MAX_MAGIC;
    }

    void Update()
    {
    }


	// Modify health by spell. If a spell is of the healing type, then the
    // argument passed to this will be a negative value, resulting in a
    // health increase.
    // Parameters- damage: the amount of damage done. Negative for healing
    // Returns- current health as an integer
	public int modifyHealth(int damage) {
        this.health -= damage;
        if (this.health < 0)
        {
            this.health = 0;
        } else if (this.health > MAX_HEALTH)
        {
            this.health = MAX_HEALTH;
        }
        return this.health;
	}

	// Modify mana by orbs or casting of spells. If the mana is being
    // increased, the argument is negative.
    // Parameters- magicPoints: the amount by which magic is changing. Negative
    //                          for orbs, indicating an increase
    // Returns- current magic as an integer. If for some reason this is called
    //          and the player does not have sufficient magic points to cast
    //          the requested spell, this will instead return -1.
	public int modifyMagic(int magicPoints)
    {
        if (magicPoints > magic)
        {
            return -1;
        }
        magic -= magicPoints;
        if (magic > MAX_MAGIC)
        {
            magic = MAX_MAGIC;
        }
        return this.magic;
    }

    // Returns the current health of the player.
    // Returns: health as an integer
    public int getHealth()
    {
        return this.health;
    }

    // Returns the current magic points of the player.
    // Returns: magic points as an integer
    public int getMagic()
    {
        return this.magic;
    }
{'fraction_non_alphanumeric': 0.08186687069625095, 'fraction_numerical': 0.006375924509053813, 'mean_word_length': 2.1834415584415585, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7462911', 'n_tokens_mistral': 1188, 'n_tokens_neox': 1062, 'n_words': 431}