summaryrefslogtreecommitdiff
path: root/src/main/java/jp/plusplus/fbs/api/FBSEntityPropertiesAPI.java
blob: d351f7b9aff4edbbcaeb40867304bf2743e6f217 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
package jp.plusplus.fbs.api;

import jp.plusplus.fbs.Registry;
import jp.plusplus.fbs.exprop.FBSEntityProperties;
import jp.plusplus.fbs.exprop.SanityManager;
import jp.plusplus.fbs.item.enchant.EnchantmentCleverness;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MathHelper;

import javax.swing.text.html.parser.Entity;

/**
 * Created by plusplus_F on 2015/09/05.
 * FBS,TFKの独自ステータスに関してはここで弄るといいと思います。
 */
public class FBSEntityPropertiesAPI {

    /**
     * playerの現在の正気度を得る
     * @param player 対象プレイヤー
     * @return 現在の正気度
     */
    public static int GetSanityPoint(EntityPlayer player){
        FBSEntityProperties prop=FBSEntityProperties.get(player);
        return prop.getSanity();
    }

    /**
     * playerの最大正気度を得る
     * @param player 対象プレイヤー
     * @return 最大正気度
     */
    public static int GetMaxSanityPoint(EntityPlayer player){
        FBSEntityProperties prop=FBSEntityProperties.get(player);
        return prop.getMaxSanity();
    }

    /**
     * プレイヤー1人を対象に発動する。そのプレイヤーに正気度を与える
     * @param player 対象プレイヤー
     * @param trial ダイスを振る回数 (0<)
     * @param max 何面ダイス? (0<)
     * @param sim 実際に結果を反映させるか否か
     * @return 変化量
     */
    public static int AddSanity(EntityPlayer player, int trial, int max, boolean sim){
        return SanityManager.addSanity(player, trial, max, sim);
    }

    /**
     * プレイヤー1人を対象に発動する。そのプレイヤーの正気度を失わせる
     * @param player 対象プレイヤー
     * @param trial ダイスを振る回数 (0<)
     * @param max 何面ダイス? (0<)
     * @param sim 実際に結果を反映させるか否か
     * @return 変化量
     */
    public static int LoseSanity(EntityPlayer player, int trial, int max, boolean sim){
        return SanityManager.loseSanity(player, trial, max, sim);
    }

    /**
     * playerの補正無しの魔術レベルを得る
     * @param player 対象プレイヤー
     * @return 魔術レベル
     */
    public static int GetMagicLevelRaw(EntityPlayer player){
        FBSEntityProperties prop=FBSEntityProperties.get(player);
        return prop.getMagicLevel();
    }

    /**
     * playerの補正済みの魔術レベルを得る
     * @param player 対象プレイヤー
     * @return 魔術レベル
     */
    public static int GetMagicLevel(EntityPlayer player){
        FBSEntityProperties prop=FBSEntityProperties.get(player);
        int l=prop.getMagicLevel();

        //ポーション効果
        int peff;
        if(player.isPotionActive(Registry.potionCleverness)){
            peff=4*(1+player.getActivePotionEffect(Registry.potionCleverness).getAmplifier());
        }
        else{
            peff=0;
        }

        //エンチャント補正
        int eSum= EnchantmentCleverness.getSum(player);
        int eeff;
        if(eSum<=5) eeff=5;
        else if(eSum<=11) eeff=5+MathHelper.floor_float(0.5f*(eSum-5));
        else eeff=8+MathHelper.floor_float(2.f/14.f*(eSum-11));

        //
        return l+peff+eeff;
    }


    /**
     * playerの魔術レベルを設定する
     * @param player 対象プレイヤー
     * @param lv 魔術レベル
     */
    public static void SetMagicLevel(EntityPlayer player, int lv){
        FBSEntityProperties prop=FBSEntityProperties.get(player);
        prop.setMagicLevel(lv);
        SanityManager.sendPacket(player);
    }

    /**
     * playerの魔術経験値を得る
     * @param player 対象プレイヤー
     * @return 魔術経験値
     */
    public static double GetMagicEXP(EntityPlayer player){
        FBSEntityProperties prop=FBSEntityProperties.get(player);
        return prop.getEXP();
    }

    /**
     * playerのLvUPに必要な魔術経験値を得る
     * @param player 対象プレイヤー
     * @return 必要な魔術経験値
     */
    public static double GetNextMagicEXP(EntityPlayer player){
        FBSEntityProperties prop=FBSEntityProperties.get(player);
        return prop.getNext();
    }

    /**
     * 魔術経験値を与える。レベルアップの判定と処理もされる
     * @param player 対象プレイヤー
     * @param exp  (0<)
     * @param sim 実際に結果を反映させるか否か
     * @return 変化量
     */
    public static double AddExp(EntityPlayer player, double exp, boolean sim){
        return SanityManager.addExp(player, exp, sim);
    }

    /**
     * その本が解読したことがあるかどうかを返す
     * @param player 対象プレイヤー
     * @param name 対象の書物
     * @return trueなら解読したことがある
     */
    public static boolean IsBookDecoded(EntityPlayer player, String name){
        return FBSEntityProperties.get(player).isDecoded(name);
    }
}