SOURCE

Ext.define('SW.view.GamePieces', {
  extend: 'Ext.view.Panel',
  pieceCodes: [1, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14],
  pieceGroups: [[1, 3, 5], [2, 4, 6], [7, 9, 11], [8, 10, 12], [13, 13, 13], [14, 14, 14]],

  round: 1,
  playerRight: true,
  toCompare: 0,
  s1: Ext.create('Ext.data.Store', {
    fields: ['name', 'code'],
    data: []
  }),
  s2: Ext.create('Ext.data.Store', {
    fields: ['name', 'code'],
    data: []
  }),
  p1: Ext.create('Ext.data.Store', {
    fields: ['name', 'code'],
    data: []
  }),
  p2: Ext.create('Ext.data.Store', {
    fields: ['name', 'code'],
    data: []
  }),
  o1: Ext.create('Ext.data.Store', {
    fields: ['name', 'code'],
    data: []
  }),
  o2: Ext.create('Ext.data.Store', {
    fields: ['name', 'code'],
    data: []
  }),

  initComponent: function() {
    var me = this;

    me.items = [{
      title: 'computer'
    },
    {
      title: 'computer'
    },
    {
      title: 'content',
      bbar: ['->', {
        text: 'GET',
        handler: function() {

}
      }]
    },
    {
      title: 'prepare',
      bbar: ['->', {
        text: 'OUT',
        handler: function() {

}
      }]
    },
    {
      title: 'store',
      xtype: 'dataview',
      itemSelector: '.ppp',
      store: me.s2,
      tpl: '<div style="display:inline-block;">{code}|</div>'bbar: ['->', {
        text: 'PICK',
        handler: function() {

}
      }]
    }];

    me.tbar = [{
      text: 'BRGIN',
      handler: function() {
        me.deal();
      }
    }];
    me.callParent(arguments);
  },

  deal: function() {
    var me = this;
    var pickupArray = me.pieceCodes;

    for (var i = 0; i < 31; i++) {
      var rnd = Math.round(Math.random() * 31);
      pickupArray[32] = pickupArray[rnd];
      pickupArray[rnd] = pickupArray[i];
      pickupArray[i] = pickupArray[32];
    }

    for (var i = 0; i < 31; i++) {
      var rnd = Math.round(Math.random() * 31);
      pickupArray[32] = pickupArray[rnd];
      pickupArray[rnd] = pickupArray[i];
      pickupArray[i] = pickupArray[32];
    }

    for (var i = 0; i < 31; i++) {
      if (i % 2 == 0) {
        me.s1.add({
          name: pickupArray[i],
          code: pickupArray[i]
        });
      } else {
        me.s2.add({
          name: pickupArray[i],
          code: pickupArray[i]
        });
      }
    }
  }

});

Ext.onReady(function() {

  Ext.create('Ext.panel.Panel', {
    renderTo: Ext.getBody(),
    width: 800,
    style: 'margin:0 auto;',
    items: [Ext.create('SW.view.GamePieces')]
  });
});
console 命令行工具 X clear

                    
>
console