⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tablecanvas.java

📁 一款麻将游戏的J2me源代码
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        if(m_aPlayers[nextPlayer()].getDiscardedCount() == 20)
        {
        Thread.sleep(450L);
        (new TableTask(this,(byte)10)).start();        	
            //m_Timer.schedule(new TableTask(this, (byte)10), 450L);
        }
        else
        if(m_aPlayers[nextPlayer()].isTen() || !m_aPlayers[nextPlayer()].gotMeldChance(m_aPlayers[currentPlayer()].lastDiscardedTile()))
         {
         Thread.sleep(450L);
        (new TableTask(this,(byte)5)).start();        	
         	   //m_Timer.schedule(new TableTask(this, (byte)5), 450L);
        }
        else
            gotMeldChance();
          }
          catch(Exception e)
          {
          }
    }

     
    private boolean isPlayerGotFan()
    {
        //return true;
        return m_aPlayers[nextPlayer()].isConcealed() || m_aPlayers[nextPlayer()].gotWindFan(m_Wall.getWind()) || m_aPlayers[nextPlayer()].gotChungFan() || m_aPlayers[nextPlayer()].gotFaFan() || m_aPlayers[nextPlayer()].gotBaiFan() || m_aPlayers[nextPlayer()].isPinHou() || m_aPlayers[nextPlayer()].isNo19() || m_aPlayers[nextPlayer()].gotSameSequence() || m_aPlayers[nextPlayer()].gotDragon() || m_aPlayers[nextPlayer()].isNonPure19WithWord() || m_aPlayers[nextPlayer()].got3ConcealedTriple() || m_aPlayers[nextPlayer()].isPongPongHou() || m_aPlayers[nextPlayer()].isSmall3Yuan() || m_aPlayers[nextPlayer()].is7Pairs() || m_aPlayers[nextPlayer()].isUnpureSameSuit() || m_aPlayers[nextPlayer()].isPure19() || m_aPlayers[nextPlayer()].isSameSuit() || m_aPlayers[nextPlayer()].isBig3Yuan();
    }

    private void gotHouChance()
    {
        if(m_aPlayers[nextPlayer()].isHuman())
            humanGotHouChance();
        else
            hou();
    }

    private void humanGotHouChance()
    {
        m_btStatus = 20;
        m_Timer = new Timer();
        m_btHint = 0;
        m_Timer.schedule(new HintTask(this), 450L, 450L);
    }

    private void gotMeldChance()
    {
    		try
    		{
        if(m_aPlayers[nextPlayer()].isHuman())
        {
            humanGotMeldChance();
        } else
        {
            m_Timer = new Timer();
        Thread.sleep(450L);
        (new TableTask(this,(byte)18)).start();            
            //m_Timer.schedule(new TableTask(this, (byte)18), 450L);
        }
      }
      catch(Exception e)
      {
      }
    }

    public void meld()
    {
        m_btStatus = 5;
        m_btTurn++;
        m_aPlayers[currentPlayer()].doMelded(m_aPlayers[currentPlayer()].currentChance());
        switch(m_aPlayers[currentPlayer()].currentChance().getType())
        {
        case 4: // '\004'
        case 5: // '\005'
        case 6: // '\006'
         
            break;

        case 7: // '\007'
            
            break;

        case 9: // '\t'
           
            break;
        }
        m_aPlayers[nextPlayer()].lostLastDiscardedTile();
        repaint();
        if(m_aPlayers[currentPlayer()].isHuman())
        {
            if(m_aPlayers[currentPlayer()].currentChance().getType() == 9)
                afterKong();
        } else
        {
            handheldDiscard();
        }
    }

    private void afterKong()
    {
        m_btStatus = 5;
        boolean flag = m_aPlayers[currentPlayer()].pick(m_Wall.getKongTile());
        repaint();
        afterPicked(flag);
    }

    private void humanGotMeldChance()
    {
        m_btStatus = 17;
        repaint();
        m_Timer = new Timer();
        m_btHint = 0;
        m_Timer.schedule(new HintTask(this), 450L, 450L);
    }

    private byte nextPlayer()
    {
        return (byte)((m_btTurn + 1) % 2);
    }
//    public void hideNotify()
//    {
//    	m_MJ13MIDlet.splashEnded();
//	    m_MJ13MIDlet.showTable=false;        
//	  }   	
    public void keyPressed(int i)
    {
    	if(i == -6)
    	{ 
    			if(m_btStatus>2&&m_btStatus!=20&&m_btStatus!=6)
    			{
    	    	m_MJ13MIDlet.splashEnded();
	    			m_MJ13MIDlet.showTable=false;    
	    		}    
    	}
    	if(!pause)
    	{
	        switch(m_btStatus)
	        {
	        case 7: // '\007'
	        case 8: // '\b'
	        case 11: // '\013'
	        case 16: // '\020'
	        case 18: // '\022'
	        default:
	            break;
	
	        case 5: // '\005'
	        case 9: // '\t'
	            if(!m_aPlayers[currentPlayer()].isTen() && m_aPlayers[currentPlayer()].isHuman())
	                keyPressedProcessInPick(i);
	            break;
	
	        case 10: // '\n'
	            keyPressedProcessInDraw(i);
	            break;
	
	        case 6: // '\006'
	            keyPressedProcessInHumanGotSelfHouChance(i);
	            break;
	
	        case 12: // '\f'
	            keyPressedProcessInShowFanTile(i);
	            break;
	
	        case 13: // '\r'
	            keyPressedProcessInShowPoint(i);
	            break;
	
	        case 14: // '\016'
	            keyPressedProcessInHumanGotSelfKongChance(i);
	            break;
	
	        case 15: // '\017'
	            keyPressedProcessInHumanSelfKongChoice(i);
	            break;
	
	        case 17: // '\021'
	            keyPressedProcessInHumanGotMeldChance(i);
	            break;
	
	        case 19: // '\023'
	            keyPressedProcessInHumanMeldChoice(i);
	            break;
	
	        case 20: // '\024'
	            keyPressedProcessInHumanGotHouChance(i);
	            break;
	        }
	}
    }

    private void keyPressedProcessInHumanGotHouChance(int i)
    {
        if(getGameAction(i) == 8)
        {
            m_Timer.cancel();
            hou();
        } else
        if(!m_aPlayers[nextPlayer()].isTen());
    }

    private void hou()
    {
    	try
    	{
        m_btStatus = 21;
        m_btHou = nextPlayer();
        
        repaint();
        m_Timer = new Timer();
        Thread.sleep(450L);
        (new TableTask(this,(byte)12)).start();        
        //m_Timer.schedule(new TableTask(this, (byte)12), 450L);
  		}
  		catch(Exception e)
  		{
  		}
    }

    private void keyPressedProcessInHumanMeldChoice(int i)
    {
        switch(getGameAction(i))
        {
        case 2: // '\002'
            m_aPlayers[nextPlayer()].leftChance();
            repaint();
            break;

        case 5: // '\005'
            m_aPlayers[nextPlayer()].rightChance();
            repaint();
            break;

        case 6: // '\006'
            humanGotMeldChance();
            break;

        case 8: // '\b'
            meld();
            break;
        }
    }

    private void keyPressedProcessInHumanGotMeldChance(int i)
    {
        switch(getGameAction(i))
        {
        case 1: // '\001'
            m_Timer.cancel();
            humanMeldChoice();
            break;

        case 8: // '\b'
            m_Timer.cancel();
            pick();
            break;
        }
    }

    private void humanMeldChoice()
    {
        m_btStatus = 19;
        repaint();
    }

    private void keyPressedProcessInHumanSelfKongChoice(int i)
    {
        switch(getGameAction(i))
        {
        case 3: // '\003'
        case 4: // '\004'
        case 7: // '\007'
        default:
            break;

        case 2: // '\002'
            if(m_aPlayers[currentPlayer()].getChanceCount() != 1)
            {
                m_aPlayers[currentPlayer()].leftChance();
                repaint();
            }
            break;

        case 5: // '\005'
            if(m_aPlayers[currentPlayer()].getChanceCount() != 1)
            {
                m_aPlayers[currentPlayer()].rightChance();
                repaint();
            }
            break;

        case 6: // '\006'
            humanGotSelfKongChance();
            break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -