Skip to content
Permalink
Browse files

#19 速度向上: 和了打点キャッシュし、同じ牌姿の和了打点を二度計算しないようにした

  • Loading branch information
kobalab committed Aug 18, 2017
1 parent 22eeaf3 commit ea7d516f7c7fabebc997c511cce3cfecf45313bf
Showing with 7 additions and 0 deletions.
  1. +7 −0 js/player.js
@@ -55,6 +55,8 @@ Majiang.Player.prototype.qipai = function(data) {

this._suanpai = new Majiang.SuanPai(this._chang.hongpai)
this._suanpai.qipai(data, this._menfeng);

this._defen_cache = {};
}

Majiang.Player.prototype.zimo = function(data, callback, option) {
@@ -734,6 +736,9 @@ Majiang.Player.prototype.tingpai = function(shoupai) {

Majiang.Player.prototype.get_defen = function(shoupai) {

var paistr = shoupai.toString();
if (this._defen_cache[paistr]) return this._defen_cache[paistr];

var menqian = (shoupai._fulou.filter(
function(m){return m.match(/[\-\+\=]/)}).length == 0);

@@ -755,6 +760,8 @@ Majiang.Player.prototype.get_defen = function(shoupai) {

var hule = Majiang.Util.hule(shoupai, null, param);

this._defen_cache[paistr] = hule.defen;

return hule.defen;
}

0 comments on commit ea7d516

Please sign in to comment.
You can’t perform that action at this time.