注意:我根据ajrwhite答案执行javascript代码.希望它可以帮助某人.
链接:http://codepen.io/eMineiro/pen/EKrNBe
打开codepen控制台以查看示例是否正常工作.
在扑克中,我们根据经销商定义玩家位置.像这样:
蓝色:小盲注和大盲注位置
绿色:迟到和经销商/迟到的头寸
黄色:中间位置
粉红色:早期的立场
所以,假设这两个数组:
players:[1,2,3,4,5,6,7,8,9,10];
positions:["bb","sb","btn","late","medium","medium","medium","early","early","early"];
Run Code Online (Sandbox Code Playgroud)
在这种情况下,"player1"是"Big Blind","player2"是"Small Blind","player3"是"按钮".....
当调用changePositions(经销商)时,我想对玩家数组进行排序.例:
changePosition(10); //means that "player10" now is the new Dealer
Run Code Online (Sandbox Code Playgroud)
结果应该是:
players:[2,1,10,9,8,7,6,5,4,3];
positions:["bb","sb","btn","late","medium","medium","medium","early","early","early"];
Run Code Online (Sandbox Code Playgroud)
在比赛期间,球员可以被淘汰.所以我有一个函数来排除"位置数组"中的"最后位置"并排除玩家.然后我需要再次调用changePosition(X),其中X是"player10"(实际经销商)左侧的下一个未被淘汰的玩家.
消除"播放器1"的示例,新阵列应该是:
players:[2,10,9,8,7,6,5,4,3];
positions:["bb","sb","btn","late","medium","medium","medium","early","early"];
Run Code Online (Sandbox Code Playgroud)
我需要再次调用changePosition(X)来确定新的位置,在这种情况下X = 2,因为"player2"位于实际经销商"player10"的左侧
changePosition(2);
Run Code Online (Sandbox Code Playgroud)
并应该导致:
players:[4,3,2,10,9,8,7,6,5];
positions:["bb","sb","btn","late","medium","medium","medium","early","early"];
Run Code Online (Sandbox Code Playgroud)
当玩家被淘汰时,我怎样才能找到新的经销商?
注意:我创建了一个名为changeNextDealer()的函数.负指数不是问题,因为下一个经销商是顺时针方向.它在代码笔链接中.
dealerArrayPosition-1; //But if bigBlind and smallBlind was eliminated simultaneously I get a negative position.
Run Code Online (Sandbox Code Playgroud)
如何将负索引(如-1)映射到最后一个位置.或-2到LastPosition-1?有快速的方法吗?
注意:这个问题仍未得到解答,但这不是本次讨论的主要问题.我想会在一个单独的帖子中提问.
我该如何进行changePosition(经销商)功能?
我已经尝试了很多,但无法弄清楚如何做到这一点.
注意:我创建了一个名为changePosition()的函数.它在codepen链接中.
给定一组单词,我需要知道哪些单词仅由一组字母组成。即使此字母是验证集的一部分,该单词的字母也不能超过允许的数量。
例:
Char set: a, a, ã, c, e, l, m, m, m, o, o, o, o, t (fixed set)
Words set: mom, ace, to, toooo, ten, all, aaa (variable set)
Run Code Online (Sandbox Code Playgroud)
结果:
mom = true
ace = true
to = true
toooo = true
ten = false (n is not in the set)
all = false (there is only 1 L in the set)
aaa = false (theres is only 2 A in the set)
Run Code Online (Sandbox Code Playgroud)
如何在Javascript中生成此正则表达式?(区分大小写不是问题)。
我尝试了以下代码,但未成功:
var str = …Run Code Online (Sandbox Code Playgroud) 我有一张叫做的桌子Incidents.我想要一个SQL查询,它返回按月拆分的事件数.开始年份是2010年,但是,结束年份将是可变的.
示例Incidents表:
DateLogged IncidentRef
----------- ------------
2015-04-05 1
2014-06-04 2
2013-01-01 3
2012-12-10 4
2011-10-15 5
2010-10-01 6
2012-12-11 7
2011-10-10 8
2010-10-10 9
Run Code Online (Sandbox Code Playgroud)
查询返回:
Year Jan Fev Mar Abr Mai Jun Jul Ago Set Out Nov Dez
2010 0 0 0 0 0 0 0 0 0 2 0 0
2011 0 0 0 0 0 0 0 0 0 2 0 0
2012 0 0 0 0 0 0 0 0 0 0 0 …Run Code Online (Sandbox Code Playgroud) javascript ×2
arrays ×1
count ×1
fullcalendar ×1
poker ×1
regex ×1
regex-greedy ×1
regex-group ×1
sql ×1
sql-server ×1