Changeset 9598
- Timestamp:
- 04/17/08 00:39:07 (5 years ago)
- Location:
- lang/java/NanikaKit/trunk/src
- Files:
-
- 2 modified
-
com/mac/tarchan/nanika/SakuraGhost.java (modified) (3 diffs)
-
test/com/mac/tarchan/nanika/NiseSatori.java (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/java/NanikaKit/trunk/src/com/mac/tarchan/nanika/SakuraGhost.java
r9535 r9598 9 9 10 10 import java.awt.Component; 11 import java.awt.EventQueue; 11 12 import java.awt.Graphics2D; 12 13 import java.awt.Rectangle; … … 454 455 * @return このゴーストへの参照 455 456 */ 456 public SakuraGhost waitTime(long ms) 457 { 458 try 459 { 460 Thread.sleep(ms); 461 } 462 catch (InterruptedException e) 463 { 464 } 465 466 return this; 467 } 468 469 /** 470 * えんいー 471 * 472 * @return このゴーストへの参照 473 */ 474 public SakuraGhost yen_e() 475 { 457 public SakuraGhost waitTime(final long ms) 458 { 459 EventQueue.invokeLater(new Runnable() 460 { 461 public void run() 462 { 463 try 464 { 465 Thread.sleep(ms); 466 } 467 catch (InterruptedException e) 468 { 469 log.error("sleep error: " + ms, e); 470 } 471 } 472 }); 473 476 474 return this; 477 475 } … … 525 523 kero.draw(g); 526 524 } 525 observer.getToolkit().sync(); 527 526 } 528 527 -
lang/java/NanikaKit/trunk/src/test/com/mac/tarchan/nanika/NiseSatori.java
r9535 r9598 52 52 53 53 /** 区切り文字 */ 54 Pattern delimiter = Pattern.compile(" (@|*|#).*");54 Pattern delimiter = Pattern.compile("[@*#](.*)"); 55 55 56 56 /** … … 63 63 public boolean load(NanikaArchive nar) 64 64 { 65 // TODO load(File ghost) をシミュレートすべきか? 65 66 log.debug("satori nar: " + nar); 66 67 File ghostDir = nar.getGhostDirectory(); … … 171 172 // トーク 172 173 log.trace("トーク=" + line); 173 line = scanTalk(s, line);174 line = scanTalk(s, s.match().group(1)); 174 175 } 175 176 else if (line.startsWith("@")) … … 204 205 private String scanTalk(Scanner s, String line) 205 206 { 206 String key = line .substring(1);207 String key = line; 207 208 StringBuilder value = new StringBuilder(); 208 209 while (true) … … 260 261 log.trace(String.format("\"%s\"=\"%s\"", key , value)); 261 262 talks.put(key , value); 262 // List<String> list = talks.get(key);263 // if (list == null)264 // {265 // list = new LinkedList<String>();266 // talks.put(key, list);267 // }268 // list.add(value);269 263 } 270 264 … … 281 275 log.trace(String.format("\"%s\"=\"%s\"", key , value)); 282 276 words.put(key , value); 283 // List<String> list = words.get(key);284 // if (list == null)285 // {286 // list = new LinkedList<String>();287 // words.put(key, list);288 // }289 // list.add(value);290 277 } 291 278 … … 302 289 { 303 290 return talks.get(key); 304 // List<String> list = talks.get(key);305 // if (list == null) return null;306 //307 // int len = list.size();308 // int index = rand.nextInt(len);309 // String talk = list.get(index);310 // return talk;311 291 } 312 292 … … 320 300 { 321 301 return words.get(key); 322 // List<String> list = words.get(key);323 // if (list == null) return null;324 //325 // int len = list.size();326 // int index = rand.nextInt(len);327 // String word = list.get(index);328 // return word;329 302 } 330 303 … … 340 313 log.debug("command: " + command); 341 314 // return "\\0\\s[0]こんにちは。\\1\\s[10]よぉ。\\e"; 315 342 316 String talk = getTalk(""); 343 317 log.debug("里々=" + talk); 318 344 319 talk = eval(talk); 345 320 log.debug("さくら=" + talk); 321 346 322 return talk; 347 323 } … … 359 335 buf.append("\\0\\s[0]\\1\\s[10]"); 360 336 int scope = 1; 361 // Pattern p = Pattern.compile("(?:|((.+)))"); 362 // while (s.hasNextLine()) 337 int wait = 100; 363 338 while (true) 364 339 { 365 String find = s.findInLine(":|( .+?)|\n|[^:(]+");340 String find = s.findInLine(":|((.+?))|、|。|\n|[^:(、。]+"); 366 341 if (find == null) break; 367 342 log.debug("find=" + find); … … 369 344 if (find.startsWith(":")) 370 345 { 346 // スコープ切り替え 371 347 scope = scope != 0 ? 0 : 1; 372 348 buf.append("\\"); … … 375 351 else if (find.startsWith("(")) 376 352 { 377 String key = find.substring(1, find.length() - 1); 353 // サーフェス切り替え 354 // String key = find.substring(1, find.length() - 1); 355 String key = s.match().group(1); 378 356 try 379 357 { … … 385 363 catch (NumberFormatException e) 386 364 { 365 // 単語置き換え 387 366 String word = getWord(key); 388 367 if (word == null) word = "{" + key + "}"; … … 390 369 } 391 370 } 371 else if (find.startsWith("、")) 372 { 373 // 読点 374 buf.append("、"); 375 buf.append("\\_w["); 376 buf.append(wait); 377 buf.append("]"); 378 } 379 else if (find.startsWith("。")) 380 { 381 // 句点 382 buf.append("。"); 383 buf.append("\\_w["); 384 buf.append(wait); 385 buf.append("]"); 386 } 392 387 else if (find.startsWith("\n")) 393 388 { 389 // 改行 394 390 buf.append("\\n"); 395 391 } 396 392 else 397 393 { 394 // テキスト 398 395 buf.append(find); 399 396 } 400 397 } 401 398 399 // さくらスクリプトを返す 402 400 return replace(replace_after, buf.toString()); 403 401 }
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)