简体   繁体   English

狩猎游戏积分系统

[英]Point System for Hunting Game

Hi friend i have a problem when solving our teacher assignment.嗨,朋友,我在解决我们的老师作业时遇到了问题。 Here is the problem:这是问题所在:

You are tasked for implementing point system for your company upcoming hunting game.您的任务是为公司即将推出的狩猎游戏实施积分系统。 There is a rule for the game:游戏有一个规则:

Point bracket点括号

  1. Bracket total kill 10 point multiplier x1括号总杀10点乘数x1
  2. Bracket total kill 20 point multiplier x2括号总击杀20点乘数x2
  3. Bracket total kill 30 point multiplier x3支架总击杀 30 点乘数 x3
  4. Bracket total kill 40 point multiplier x4支架总击杀 40 点乘数 x4
  5. Bracket total kill 50 point multiplier x5支架总击杀 50 点乘数 x5
  6. Bracket total kill above 50 point multiplier x6括号总击杀超过 50 点乘数 x6

Point bracket explanation: *if total kill less or the same than 10, point will be 10 *if total kill between 10 and 20, point will be 2x of total kill between 10 and 20, plus 1x of 10 total kill点括号说明:*如果总击杀数小于或等于 10,则得分为 10 *如果总击杀数在 10 到 20 之间,点数将为 10 到 20 之间总击杀数的 2 倍,再加上 10 次总击杀数的 1 倍

  • if total kill between 20 and 30, point will be 2x of total kill between 10 and 20, plus 3x of total kill over 20, plus 1x of 10 total kill如果总击杀数在 20 到 30 之间,则点数将是 10 到 20 之间总击杀数的 2 倍,加上 20 次以上总击杀数的 3 倍,再加上 10 次总击杀数的 1 倍
  • if total kill above 30, point will be 2x of total kill between 10 and 20, plus 3x of total kill between 20 and 30, plus 4x total kill over 30, plus 1x of 10 total kill如果总击杀数超过 30,则点数将是 10 到 20 之间总击杀数的 2 倍,加上 20 到 30 之间总击杀数的 3 倍,加上 30 上总击杀数的 4 倍,再加上 10 次总击杀数的 1 倍
  • and so on等等

Ex:前任:

  1. total kill 10, point 10总击杀 10,点 10
  2. total kill 27, point 51总击杀 27,点 51
  3. total kill 33, point 72总击杀 33,点 72
  4. total kill 120, point 570总击杀 120,点 570
  5. total kill 60, point 210总击杀 60,点 210

I have tried to code it in js, but i think there is some missing logic.我曾尝试用 js 对其进行编码,但我认为缺少一些逻辑。 can you help me ?你能帮助我吗 ?

function calculatePoint(totalKill){
    if(totalKill <= 10){
        return 10;
    } else if ( totalKill >= 10 && totalKill <=20){
        return 2*totalKill + 1*10*totalKill;
    } else if ( totalKill>=20 &&  totalKill <=30){
        return 3*totalKill + 1*10*totalKill;
    } else if (totalKill>=30){
        return 2*totalKill + 3*totalKill + 4*totalKill+1*10*totalKill;
    } 
}

well for starters you are overlapping >=10 and <=10 - and others.对于初学者来说,您重叠 >=10 和 <=10 - 和其他人。 be clear about less than 10, between 10 and 20, etc..清楚小于 10,在 10 和 20 之间,等等。

next up is 2x for points between 10 and 20. you are just multiplying 2xtotalKill - you probably need something like 2x(totalKill-10), and 3x(totalKill-20), etc..对于 10 到 20 之间的点,接下来是 2x。您只是乘以 2xtotalKill - 您可能需要诸如 2x(totalKill-10) 和 3x(totalKill-20) 之类的东西。

you don't say what is not working?你不说什么是行不通的? if you provide more details about what you have tried, and what the problem is - you might get more assistance...如果您提供有关您尝试过的内容以及问题所在的更多详细信息 - 您可能会获得更多帮助...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM