[英]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点括号
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 倍
Ex:前任:
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.