---
title: "asdasd"
author: "ggyyleo"
date: "2010-04-30T14:55:00Z"
tags: []
categories: ["编程语言"]
slug: "asdasd"
draft: false
lastmod: "2010-04-30T14:55:00Z"
id: 657028
url: "https://ggyyleo.iteye.com/blog/657028"
---

```java
def humUnits = ['footman','gryphonrider','knight','peasant','priest','rifleman','seigeengine','sorceress','spellbreaker','summonwaterelemental','dragonhawk','flyingmachine','mortarteam']
def orcUnits = ['wyvernrider','demolisher','grunt','headhunter','kotobeast','peon','raider','shaman','spiritwalker','spiritwolf','tauren','trollbatrider','witchdoctor']
def neUnits = ['mountaingiant','wisp','archer','chimaera','druidoftheclaw','druidofthetalon','dryad','faeriedragon','glaivethrower','hippogriff','huntress']
def udUnits = ['shade','abomination','acolyte','banshee','cryptfiend','frostwyrm','gargoyle','ghoul','meatwagon','necromancer','obsidianstatue','destroyer']

def units = [ne:neunits,hum:humunits,orc:orcunits,ud:udunits]
def content = ""

units.each{k,v->
    def unitRows = ""
    def race = k
    v.each{
    def unitName = it
    
    
    def soundSrcStrings = [ready:'', what:'',yes:'',death:'',pissed:'']
//    def soundSrcs = getSoundSrcForUnit(it)//filename list
    def soundSrcs = ['footmanready','footmanready2']
    def counter = [:]
    soundSrcs.each{
        ['ready','what','yes','death','pissed'].each{
        soundType->
             if(it.toLowerCase().indexOf(soundType) != -1){
            def readyCounter = counter[soundtype]
            if(!readyCounter){
                soundSrcStrings[soundtype] += """wsb:soundSrc="@raw/${it}" """
                counter[soundtype] = 2
                }
            else{
                soundSrcStrings[soundtype] += """wsb:soundSrc${counter[soundtype]}="@raw/${it}" """
                counter[soundtype] = counter[soundtype]+1
             }
        }
        }
       
    }

        
    def unitRow = """<TableRow android:layout_marginBottom="5dip"  ><ImageView android:src="@drawable/${unitName}" style="@style/iconStyle"/>
                            <com.jleo.war3.SoundingButton android:text="Ready"
                                ${soundSrcStrings['ready']} style="@style/${race}ButtonStyle"/>
                            <com.jleo.war3.SoundingButton android:text="What"
                                ${soundSrcStrings['what']} style="@style/${race}ButtonStyle"/>
                            <com.jleo.war3.SoundingButton android:text="Yes"
                                ${soundSrcStrings['yes']} style="@style/${race}ButtonStyle"/>
                            <com.jleo.war3.SoundingButton android:text="Death"
                                ${soundSrcStrings['death']} style="@style/${race}ButtonStyle"/>
                            <com.jleo.war3.SoundingButton android:text="Pissed"
                                ${soundSrcStrings['pissed']} style="@style/${race}ButtonStyle"/></TableRow>"""
    
                               
    
    unitRows += unitRow                            
                }
                def id

                if(k.equals('hum'))
                    id = "human"
                if(k.equals('orc'))
                    id = "orc"
                 if(k.equals('ud'))
                    id = "undead"
                  if(k.equals('ne'))
                    id = "nightElf"
                 def template = """<ScrollView android:padding="10dip" android:id="@+id/${id}"
                android:layout_width="fill_parent" android:layout_height="wrap_content"
                android:scrollbars="none"><TableLayout
                        android:layout_width="fill_parent" android:layout_height="fill_parent"
                        android:stretchColumns="0" android:background="@drawable/nebg">
                        
                           ${unitRows}
                        
                    </TableLayout></ScrollView>
                    """
                    content += template
                }
                
       new File("c:\\content.xml").write(content)        
```