| | 722 | |
| | 723 | /** |
| | 724 | * @author FoN |
| | 725 | * |
| | 726 | * This class is to congregate all the stats so they can be organised and added + removed easily |
| | 727 | */ |
| | 728 | private class Statistics |
| | 729 | { |
| | 730 | //stats |
| | 731 | private int m_wbKill; |
| | 732 | private int m_javKill; |
| | 733 | private int m_spiderKill; |
| | 734 | private int m_levKill; |
| | 735 | private int m_terrKill; |
| | 736 | private int m_weaselKill; |
| | 737 | private int m_lancKill; |
| | 738 | private int m_sharkKill; |
| | 739 | private int m_deaths; |
| | 740 | private int m_score; |
| | 741 | private int m_teamKills; |
| | 742 | private int m_avgRepelCount; |
| | 743 | private int m_flagClaimed; |
| | 744 | |
| | 745 | //others |
| | 746 | private int m_shipType; |
| | 747 | |
| | 748 | private final int MAXIMUM_RATIO = 4; |
| | 749 | |
| | 750 | public Statistics(int shipType) |
| | 751 | { |
| | 752 | m_shipType = shipType; |
| | 753 | reset(); |
| | 754 | } |
| | 755 | |
| | 756 | /** |
| | 757 | * Method getRating. |
| | 758 | * This returns the rating for the player according to this: |
| | 759 | * |
| | 760 | * warbird: points * (1 + (2x + y)/z) * (1 + 0.1x + 0.01y) |
| | 761 | * x = terr kills |
| | 762 | * y = shark kills |
| | 763 | * z = kills |
| | 764 | * |
| | 765 | * jav: points * (1 + .05x - .1y) * (1 + 0.1z) |
| | 766 | * x = kills |
| | 767 | * y = teamkills |
| | 768 | * z = terr kills |
| | 769 | * |
| | 770 | * spiders: points * .8kills/deaths * (1 + .05x + .005y) |
| | 771 | * x = terr kills |
| | 772 | * y = shark kills |
| | 773 | * |
| | 774 | * terr: points * (x/y) * (1 + 0.05z) |
| | 775 | * x = kills |
| | 776 | * y = deaths |
| | 777 | * z = terr kills |
| | 778 | * |
| | 779 | * weasel: points * (x/y) * (1 + 0.2z + 0.2a) |
| | 780 | * x = kills |
| | 781 | * y = deaths |
| | 782 | * z = terr kills |
| | 783 | * a = num of times flag claimed |
| | 784 | * |
| | 785 | * lanc: points * (x/y) * (1 + 0.05z + 0.001(a + b + c + d)) |
| | 786 | * x = kills |
| | 787 | * y = deaths |
| | 788 | * z = terr kills |
| | 789 | * a = jav kills |
| | 790 | * b = lanc kills |
| | 791 | * c = weasel kills |
| | 792 | * d = wb kills |
| | 793 | * |
| | 794 | * shark: points * (1 + .02x - .05y + .1z) * (1 + 0.4(x/a)) * (3 / avgRepelCount) |
| | 795 | * x = kills |
| | 796 | * y = teamkills |
| | 797 | * z = terr kills |
| | 798 | * a = deaths |
| | 799 | * |
| | 800 | * Original idea by Randedl |
| | 801 | * |
| | 802 | * @author FoN |
| | 803 | * |
| | 804 | * @return int which is the rating depending on the shiptype |
| | 805 | */ |
| | 806 | public int getRating() |
| | 807 | { |
| | 808 | int rating = 0; |
| | 809 | |
| | 810 | switch (m_shipType) |
| | 811 | { |
| | 812 | case 1 : //warbird |
| | 813 | if (getTotalKills() == 0) //can't divide by zero |
| | 814 | return (int) (m_score * MAXIMUM_RATIO * (1 + 0.1 * m_terrKill + 0.01 * m_sharkKill)); |
| | 815 | rating = (int) (m_score * (1 + (2 * m_terrKill + m_sharkKill/getTotalKills())) * (1 + 0.1 * m_terrKill + 0.01 * m_sharkKill)); |
| | 816 | return rating; |
| | 817 | |
| | 818 | case 2 : //jav |
| | 819 | rating = (int) (m_score * (1 + 0.05 * getTotalKills() - 0.1 * m_teamKills) * (1 + 0.1 * m_terrKill)); |
| | 820 | return rating; |
| | 821 | |
| | 822 | case 3 : //spider |
| | 823 | if (m_deaths == 0) //can't divide by zero |
| | 824 | return (int) (m_score * MAXIMUM_RATIO * (1 + 0.05 * m_terrKill + 0.005 * m_sharkKill)); |
| | 825 | rating = (int) (m_score * (0.8 * getTotalKills() / m_deaths) * (1 + 0.05 * m_terrKill + 0.005 * m_sharkKill)); |
| | 826 | return rating; |
| | 827 | |
| | 828 | case 4 : //lev |
| | 829 | rating = m_score; |
| | 830 | return rating; |
| | 831 | |
| | 832 | case 5 : //terr |
| | 833 | if (m_deaths == 0) |
| | 834 | return (int) (m_score * MAXIMUM_RATIO * (1 + 0.05 * m_terrKill)); //can't divide by zero |
| | 835 | rating = (int) (m_score * (getTotalKills() / m_deaths) * (1 + 0.5 * m_terrKill)); |
| | 836 | return rating; |
| | 837 | |
| | 838 | case 6 : //weasel |
| | 839 | if (m_deaths == 0) //can't divide by zero |
| | 840 | return (int) (m_score * MAXIMUM_RATIO * (1 + 0.2 * m_terrKill + 0.2 * m_flagClaimed)); |
| | 841 | rating = (int) (m_score * (getTotalKills()/m_deaths) * (1 + 0.2 * m_terrKill + 0.2 * m_flagClaimed)); |
| | 842 | return rating; |
| | 843 | |
| | 844 | case 7 : //lanc |
| | 845 | if (m_deaths == 0) //can't divide by zero |
| | 846 | return (int) (m_score * MAXIMUM_RATIO * (1 + 0.05 * m_terrKill + 0.001 * (m_wbKill + m_javKill + m_weaselKill + m_lancKill))); |
| | 847 | rating = (int) (m_score * (getTotalKills()/m_deaths) * (1 + 0.05 * m_terrKill + 0.001 * (m_wbKill + m_javKill + m_weaselKill + m_lancKill))); |
| | 848 | return rating; |
| | 849 | |
| | 850 | case 8 : //shark |
| | 851 | if (m_deaths == 0 && (getAverageRepelCount() != 0)) |
| | 852 | return (int) (m_score * (1 + 0.02 * getTotalKills() - 0.05 * m_teamKills + 0.1 * m_terrKill) * (1 + 0.4 * MAXIMUM_RATIO) * (3 / getAverageRepelCount())); |
| | 853 | else if (m_deaths == 0 && getAverageRepelCount() == 0) |
| | 854 | return (int) (m_score * (1 + 0.02 * getTotalKills() - 0.05 * m_teamKills + 0.1 * m_terrKill) * (1 + 0.4 * MAXIMUM_RATIO) * MAXIMUM_RATIO); |
| | 855 | else if (getAverageRepelCount() == 0) |
| | 856 | return (int) (m_score * (1 + 0.02 * getTotalKills() - 0.05 * m_teamKills + 0.1 * m_terrKill) * (1 + 0.4 * getTotalKills() / m_deaths) * MAXIMUM_RATIO); |
| | 857 | else |
| | 858 | { |
| | 859 | rating = (int) (m_score * (1 + 0.02 * getTotalKills() - 0.05 * m_teamKills + 0.1 * m_terrKill) * (1 + 0.4 * getTotalKills() / m_deaths) * (3 / getAverageRepelCount())); |
| | 860 | return rating; |
| | 861 | } |
| | 862 | |
| | 863 | default : //if errored |
| | 864 | rating = m_score; |
| | 865 | return rating; |
| | 866 | } |
| | 867 | |
| | 868 | } |
| | 869 | |
| | 870 | /** |
| | 871 | * sets all the stat variables to zero or their initial values |
| | 872 | */ |
| | 873 | private void reset() |
| | 874 | { |
| | 875 | m_wbKill = 0; |
| | 876 | m_javKill = 0; |
| | 877 | m_spiderKill = 0; |
| | 878 | m_levKill = 0; |
| | 879 | m_terrKill = 0; |
| | 880 | m_weaselKill = 0; |
| | 881 | m_lancKill = 0; |
| | 882 | m_sharkKill = 0; |
| | 883 | m_deaths = 0; |
| | 884 | m_score = 0; |
| | 885 | m_teamKills = 0; |
| | 886 | m_flagClaimed = 0; |
| | 887 | m_avgRepelCount = 0; |
| | 888 | } |
| | 889 | |
| | 890 | /** |
| | 891 | * Adds up all the shiptype kills and returns total |
| | 892 | * @return int |
| | 893 | */ |
| | 894 | public int getTotalKills() |
| | 895 | { |
| | 896 | return m_wbKill + m_javKill + m_spiderKill + m_levKill + m_terrKill + m_weaselKill + m_lancKill + m_sharkKill; |
| | 897 | } |
| | 898 | |
| | 899 | public float getKillDeathRatio() |
| | 900 | { |
| | 901 | if (m_deaths == 0) //cant divide by zero |
| | 902 | return getTotalKills(); |
| | 903 | return getTotalKills() / m_deaths; |
| | 904 | } |
| | 905 | |
| | 906 | /** |
| | 907 | * Returns the m_javKill. |
| | 908 | * @return int |
| | 909 | */ |
| | 910 | public int getJavKill() |
| | 911 | { |
| | 912 | return m_javKill; |
| | 913 | } |
| | 914 | |
| | 915 | /** |
| | 916 | * Returns the m_lancKill. |
| | 917 | * @return int |
| | 918 | */ |
| | 919 | public int getLancKill() |
| | 920 | { |
| | 921 | return m_lancKill; |
| | 922 | } |
| | 923 | |
| | 924 | /** |
| | 925 | * Returns the m_levKill. |
| | 926 | * @return int |
| | 927 | */ |
| | 928 | public int getLevKill() |
| | 929 | { |
| | 930 | return m_levKill; |
| | 931 | } |
| | 932 | |
| | 933 | /** |
| | 934 | * Returns the m_sharkKill. |
| | 935 | * @return int |
| | 936 | */ |
| | 937 | public int getSharkKill() |
| | 938 | { |
| | 939 | return m_sharkKill; |
| | 940 | } |
| | 941 | |
| | 942 | /** |
| | 943 | * Returns the m_spiderKill. |
| | 944 | * @return int |
| | 945 | */ |
| | 946 | public int getSpiderKill() |
| | 947 | { |
| | 948 | return m_spiderKill; |
| | 949 | } |
| | 950 | |
| | 951 | /** |
| | 952 | * Returns the m_terrKill. |
| | 953 | * @return int |
| | 954 | */ |
| | 955 | public int getTerrKill() |
| | 956 | { |
| | 957 | return m_terrKill; |
| | 958 | } |
| | 959 | |
| | 960 | /** |
| | 961 | * Returns the m_wbKill. |
| | 962 | * @return int |
| | 963 | */ |
| | 964 | public int getWbKill() |
| | 965 | { |
| | 966 | return m_wbKill; |
| | 967 | } |
| | 968 | |
| | 969 | /** |
| | 970 | * Returns the m_weaselKill. |
| | 971 | * @return int |
| | 972 | */ |
| | 973 | public int getWeaselKill() |
| | 974 | { |
| | 975 | return m_weaselKill; |
| | 976 | } |
| | 977 | |
| | 978 | /** |
| | 979 | * Sets the m_javKill. |
| | 980 | * Increments it by one |
| | 981 | */ |
| | 982 | public void setJavKill() |
| | 983 | { |
| | 984 | m_javKill++; |
| | 985 | } |
| | 986 | |
| | 987 | /** |
| | 988 | * Sets the m_lancKill. |
| | 989 | * Increments it by one |
| | 990 | */ |
| | 991 | public void setLancKill() |
| | 992 | { |
| | 993 | m_lancKill++; |
| | 994 | } |
| | 995 | |
| | 996 | /** |
| | 997 | * Sets the m_levKill. |
| | 998 | * Increments it by one |
| | 999 | */ |
| | 1000 | public void setLevKill() |
| | 1001 | { |
| | 1002 | m_levKill++; |
| | 1003 | } |
| | 1004 | |
| | 1005 | /** |
| | 1006 | * Sets the m_sharkKill. |
| | 1007 | * Increments it by one |
| | 1008 | */ |
| | 1009 | public void setSharkKill() |
| | 1010 | { |
| | 1011 | m_sharkKill++; |
| | 1012 | } |
| | 1013 | |
| | 1014 | /** |
| | 1015 | * Sets the m_spiderKill. |
| | 1016 | * Increments it by one |
| | 1017 | */ |
| | 1018 | public void setSpiderKill() |
| | 1019 | { |
| | 1020 | m_spiderKill++; |
| | 1021 | } |
| | 1022 | |
| | 1023 | /** |
| | 1024 | * Sets the m_terrKill. |
| | 1025 | * Increments it by one |
| | 1026 | */ |
| | 1027 | public void setTerrKill() |
| | 1028 | { |
| | 1029 | m_terrKill++; |
| | 1030 | } |
| | 1031 | |
| | 1032 | /** |
| | 1033 | * Sets the m_wbKill. |
| | 1034 | * Increments it by one |
| | 1035 | */ |
| | 1036 | public void setWbKill() |
| | 1037 | { |
| | 1038 | m_wbKill++; |
| | 1039 | } |
| | 1040 | |
| | 1041 | /** |
| | 1042 | * Sets the m_weaselKill. |
| | 1043 | * Increments it by one |
| | 1044 | */ |
| | 1045 | public void setWeaselKill() |
| | 1046 | { |
| | 1047 | m_weaselKill++; |
| | 1048 | } |
| | 1049 | |
| | 1050 | /** |
| | 1051 | * Returns the m_deaths. |
| | 1052 | * @return int |
| | 1053 | */ |
| | 1054 | public int getDeaths() |
| | 1055 | { |
| | 1056 | return m_deaths; |
| | 1057 | } |
| | 1058 | |
| | 1059 | /** |
| | 1060 | * Sets the m_deaths. |
| | 1061 | */ |
| | 1062 | public void setDeaths() |
| | 1063 | { |
| | 1064 | m_deaths++; |
| | 1065 | } |
| | 1066 | |
| | 1067 | /** |
| | 1068 | * Changes the death via the input |
| | 1069 | * @ param deaths The deaths to be changed to |
| | 1070 | */ |
| | 1071 | public void changeDeaths(int deaths) |
| | 1072 | { |
| | 1073 | m_deaths = deaths; |
| | 1074 | } |
| | 1075 | |
| | 1076 | /** |
| | 1077 | * Returns the m_score. |
| | 1078 | * @return int |
| | 1079 | */ |
| | 1080 | public int getScore() |
| | 1081 | { |
| | 1082 | return m_score; |
| | 1083 | } |
| | 1084 | |
| | 1085 | /** |
| | 1086 | * Adds to the m_score. |
| | 1087 | * @param score The m_score to set |
| | 1088 | */ |
| | 1089 | public void setScore(int score) |
| | 1090 | { |
| | 1091 | m_score += score; |
| | 1092 | } |
| | 1093 | |
| | 1094 | /** |
| | 1095 | * Returns the m_teamKills. |
| | 1096 | * @return int |
| | 1097 | */ |
| | 1098 | public int getTeamKills() |
| | 1099 | { |
| | 1100 | return m_teamKills; |
| | 1101 | } |
| | 1102 | |
| | 1103 | /** |
| | 1104 | * Sets the m_teamKills. |
| | 1105 | */ |
| | 1106 | public void setTeamKills() |
| | 1107 | { |
| | 1108 | m_teamKills++; |
| | 1109 | } |
| | 1110 | |
| | 1111 | /** |
| | 1112 | * Returns the m_avgRepelCount. |
| | 1113 | * @return int |
| | 1114 | */ |
| | 1115 | public int getAverageRepelCount() |
| | 1116 | { |
| | 1117 | if (m_deaths == 0) |
| | 1118 | return m_avgRepelCount / 1; //can't divide by zero; |
| | 1119 | return m_avgRepelCount/m_deaths; |
| | 1120 | } |
| | 1121 | |
| | 1122 | /** |
| | 1123 | * Returns the m_flagClaimed. |
| | 1124 | * @return int |
| | 1125 | */ |
| | 1126 | public int getFlagClaimed() |
| | 1127 | { |
| | 1128 | return m_flagClaimed; |
| | 1129 | } |
| | 1130 | |
| | 1131 | /** |
| | 1132 | * Sets the m_avgRepelCount. |
| | 1133 | * @param m_avgRepelCount The m_avgRepelCount to set |
| | 1134 | */ |
| | 1135 | public void setAverageRepelCount(int avgRepelCount) |
| | 1136 | { |
| | 1137 | m_avgRepelCount += avgRepelCount; |
| | 1138 | } |
| | 1139 | |
| | 1140 | /** |
| | 1141 | * Sets the m_flagClaimed. |
| | 1142 | */ |
| | 1143 | public void setFlagClaimed() |
| | 1144 | { |
| | 1145 | m_flagClaimed++; |
| | 1146 | } |
| | 1147 | |
| | 1148 | } |