1 module de.Connection; 2 3 import std.array; 4 import std.conv; 5 import std.datetime; 6 import rule.Repository; 7 import rule.GeneratedRule; 8 import de.Phrases; 9 10 class Connection : Phrases 11 { 12 override string[] rule(AnnouncementProperties[] parts, AnnouncementProperties link, AnnouncementProperties additional, AnnouncementProperties substitution, AnnouncementProperties regularTrain, AnnouncementProperties[] connections, AnnouncementProperties[] laterConnections, AnnouncementProperties[] alternativeJourneys) 13 { 14 output.clear; 15 16 with(parts[0]) 17 { 18 if ( ! station.empty) 19 { 20 stationName(station); 21 append("-"); 22 } 23 append("Bahnsteig"); 24 append(track); 25 append("!"); 26 foreach (int connections_index, connection; connections) 27 { 28 if (connections_index == 0) 29 { 30 if (connections_index == connections.length-1) 31 { 32 append("Die nächste Reisemöglichkeit ist:"); 33 } 34 else 35 { 36 append("Die nächsten Reisemöglichkeiten sind:"); 37 } 38 } 39 productName(connection.product); 40 append("nach"); 41 stationName(connection.destination); 42 append(", Planabfahrt"); 43 timeOfDay(connection.departureTime); 44 if (connection.track == "BUS" || connection.isCancelled) 45 { 46 append(". Dieser Zug wird als Schienenersatzverkehr geführt"); 47 } 48 else 49 { 50 append(", Bahnsteig"); 51 append(connection.track); 52 } 53 if (connections_index == connections.length-1) 54 { 55 append("."); 56 } 57 else 58 { 59 append(","); 60 } 61 if ( ! connection.journeyBreaks.empty) 62 { 63 if (station != connection.journeyBreaks[0].firstServicedStop) 64 { 65 if ( ! connection.busReplacement.empty && connection.busReplacement[0] == connection.journeyBreaks[0].lastServicedStop) 66 { 67 append("Dieser Zug wird zwischen"); 68 stationName(connection.journeyBreaks[0].lastServicedStop); 69 append("und"); 70 stationName(connection.journeyBreaks[0].firstServicedStop); 71 append("als Schienenersatzverkehr geführt"); 72 } 73 else 74 { 75 append("Dieser Zug fällt zwischen"); 76 stationName(connection.journeyBreaks[0].lastServicedStop); 77 append("und"); 78 stationName(connection.journeyBreaks[0].firstServicedStop); 79 append("aus"); 80 if ( ! connection.reason.empty) 81 { 82 append(". Grund dafür"); 83 reasonText(connection.reason); 84 } 85 } 86 if (connections_index == connections.length-1) 87 { 88 append("."); 89 } 90 else 91 { 92 append(","); 93 } 94 } 95 } 96 } 97 } 98 99 return output.data; 100 } 101 102 static this() 103 { 104 Connection inst = new Connection(); 105 inst.type = "CONNECTION"; 106 inst.language = "de"; 107 Repository.register(inst); 108 } 109 }