// this method is called from the rpc method of the attacked Hexfield by the defending player to the attacking player(!). it is called after the fight is over and the attacker has won.
    public void attackSuccess(GameObject destination, int survivingTroops, Vector3 pos, bool win)
    {
        if (win)
        {
            // game ends if the win condition was fulfilled. attacking player is the winner.
            gameEnd(win);
        }
        else
        {
            // build militarynode on conquered field for free(=earn+build)
            earn(150);
            int builder = Network.isServer ? 1:0;
            destination.GetComponent<HexField>().owner = Network.isServer ? 1 : 2;
            destination.networkView.RPC("buildMilitary", RPCMode.AllBuffered, destination.networkView.viewID, selectedRace, builder);
            Specialisation spec = new MilitarySpecialisation(destination, destination.transform.position);
            buildingNodes.Add(spec);
            audio.PlayOneShot(building);

            destination.GetComponent<HexField>().isFilled = true;
            destination.GetComponent<HexField>().spec = spec;
            destination.networkView.RPC("setSpecialisation", RPCMode.AllBuffered, "Military");
            // set troops to surviving troops and weapontypoe to the weapontype of the troops which have attacked
            ((MilitarySpecialisation)spec).Troops = survivingTroops;
            ((MilitarySpecialisation)spec).WeaponType = ((MilitarySpecialisation)sendOrigin.GetComponent<HexField>().spec).WeaponType;
            ((MilitarySpecialisation)sendOrigin.GetComponent<HexField>().spec).WeaponType = 0;
            destination.GetComponent<HexField>().colorOwnedArea();
        }
    }
    // this method is called from the popupmenu when the player decides to build something
    // the parameters define the type of specialisation to build, the hex and its position where to build the specialisation
    public bool build(string type, GameObject hex, Vector3 pos)
    {
        Specialisation newBuilt;
        switch (type)
        {
            case "Economy":
                newBuilt = new EconomySpecialisation(hex, pos);
                break;
            case "Military":
                newBuilt = new MilitarySpecialisation(hex, pos);
                break;
            default:
                newBuilt = null;
                break;
        }

        if (newBuilt != null)
        {
            if (spend(newBuilt.Cost))
            {
                // only true if the player can afford the costs of the new specialisation
                hex.GetComponent<HexField>().isFilled = true;
                hex.GetComponent<HexField>().spec = newBuilt;
                NetworkView nview = hex.networkView;
                nview.RPC("setSpecialisation", RPCMode.AllBuffered, type);

                int owner;
                if(Network.isServer) owner = 1;
                else owner = 2;
                nview.RPC("setOwner", RPCMode.AllBuffered, nview.viewID, owner);
                // add specialisation to the list of specialisations that are currently built
                buildingNodes.Add(newBuilt);
                audio.PlayOneShot(building);
                return true;
            }
        }
        // player cannot afford the specialisation. play negative sound
        audio.PlayOneShot(denied);
        return false;
    }